mv: target `filename' is not a directory
I'm trying to write a short script that changes the file names in the folders containing music (mp3) files. The current format is often along the lines of:
"Artist Name - Album Name - tracknum - Trackname.mp3" and I'd like to shorten this to just: "tracknum Trackname.mp3" So, I've tried the following approach Code:
for i in *.mp3; do Code:
mv: target `Trackname.mp3' is not a directory Code:
echo $j$k Cheers |
I'll bet the problem is spaces in your filenames. They can really mess up scripting. Most *nix users learn to avoid them in filenames whenever possible.
Add this to the start of your script. It changes the internal field separator to a newline only, and your script will treat spaces as just another character from then on. Code:
#!/bin/bash |
So I take it it worked then. :)
|
Aye, worked a treat. Cheers!
|
Install: target p is not a directory
I have an error same as per above 'Title'. In fact i am trying to install aircrack-2.41 on Backtrack 5 which is installed on Virtual Box. It will come to terminal screen when;
I run a command 'root@bt:~/aircrack-2.41# make install'. In result of this i found following response; a) install -d /usr/local/bin b) install -m 755 aircrack airdecap arpforge aireplay airodump airmon.sh mergeivs p c) cap2inv /usr/local/bin When i try to apply [install -m 755 aircrack airdecap arpforge aireplay airodump airmon.sh mergeivs p ] it appears like this; [root@bt:~/aircrack-2.41#install -m 755 aircrack airdecap arpforge aireplay airodump airmon.sh mergeivs p] install: target p is not a directory Can somebody please help me to solve this problem?? why p directory is not found?? can i create a p directory myself to complete install?? help me....!!!!!!!!!!!!!! |
Quote:
|
First of all, please don't re-open old threads unless you have something substantial to add to that discussion, such as a correction or updated information. If you have a new question of your own, start a new thread and refer back to the old one if necessary. Thanks.
Besides, I don't think your question has anything directly to do with the original subject here. His problem was with improperly quoted variables leading to word-splitting in the arguments, while yours seems to have something to do with either the syntax of your install command or the conditions of the directory you passed to it. But I'm not familiar with that comman, so I can't say. But you have given me an opportunity to update one of my old posts. :D After several more years of experience, I would no longer give the advice that I did then. First, I now understand that changing IFS should be generally avoided, due to possible obscurity in what the code is doing, and that proper quoting is usually the best solution. Second, when you do need to change IFS to newline or other non-printing characters, you can use ansi-c style quoting: Code:
IFS=$'\n' Code:
for fname in *.mp3; do |
Quote:
you need : Code:
find -iname "*.mp3" | while read -r i ; do echo "$i" ; done Code:
|
@Xeratul, This is what I was talking about. The thread is over three years old, and I'm sure the OP has long ago moved on to new things. The only reason to add anything new is to help others coming across it later.
As for your suggestions, find is only necessary if you need to search recursively or otherwise match files by criteria that simple globbing can't handle, and even then you shouldn't just pipe the results directly into a loop like that. Unix file paths can contain any character (except one), so there's always a chance that one can contain an embedded newline. The exception is the null, which is why it's recommended for use as the delimiting character in cases like this. How can I read a file (data stream, variable) line-by-line (and/or field-by-field)? http://mywiki.wooledge.org/BashFAQ/001 How can I find and deal with file names containing newlines, spaces or both? http://mywiki.wooledge.org/BashFAQ/020 There are other issues involved too. If your changes include modifying the pathname, for example, you need to be sure to use the -depth option to process things in a safe order. And anything done in a pipe chain may suffer from subshell-related variable scoping. How can I rename all my *.foo files to *.bar, or convert spaces to underscores, or convert upper-case file names to lower case? http://mywiki.wooledge.org/BashFAQ/030 I set variables in a loop that's in a pipeline. Why do they disappear after the loop terminates? Or, why can't I pipe data to read? http://mywiki.wooledge.org/BashFAQ/024 So to safely use find, something like this would be better: Code:
while IFS='' read -r -d '' fname ; do |
Quote:
done < <( find . -depth -type f -name '*.mp3' -print0 ) Your inputs are welcome Sh could do it one day, would be useful. All my init.d script are based on sh that I employ mostly. I try to stick to sh for minimal install. dont really know why. |
All times are GMT -5. The time now is 05:54 AM. |