PDA

View Full Version : do something with all files in all subdirs



Superstoned
08-27-2003, 07:16 PM
hi,

I want to remove the idv2 tags from my musepack files, which i have accidentally added. but my files are put in several directory's (in fact, every band+every album in his own dir). I downloaded a command-line tool, to remove the idv2 tag, with a command like

idv2edit -remove <filename>

but... how to do this for all files in all dirs, in one command??? I guess it is possible, but how... I dont know. (actually I dont know much 'bout the commandline, and i cant find it in manuals, how-to's etc)

baldyeti
08-27-2003, 11:55 PM
If your 'idv2edit' command can only act on one file at a time, try:

for $file in $( find /startdir -name '*.mp3' )
do
idv2edit -remove $file
done
If it can handle a list of files, there's a slightly simpler form:

$ find /startdir -name '*.mp3' | xargs idv2edit -remove
I suggest you first susbtitue a plain 'echo' to your command, so you'll
see exactly which files will be touched.

Superstoned
08-28-2003, 11:29 AM
hi...

I tried your commands, and, after some playing with man etc I was still unable to use them. find didnt return any mp3z, but I found out that if I modified the command into: find -name '*/*/*.mp3', it did return the filenames. but that didnt seem to change anything, so I guess id3v2edit doesnt accept more files.

so, I tried to copy-paste your first idea:

(the 'find' part works, at least, it returns alot of mpc-files)

for $file in $( find -name '*.mpc' ) ; do id3v2 -d $file ; done

but this only returned "bash: `$file': not a valid identifier". and I dont even know what that means... I understand what the the intention is of the piece of code, but I cant solve this problem. :(
tried read the man for bash, it told me that it should be allright, as far as I understood it.

Superstoned
08-28-2003, 11:38 AM
(the first command replies: xargs: unmatched single quote)

baldyeti
08-28-2003, 12:24 PM
for $file in $( find -name '*.mpc' ) ....
Sorry, that should be: "for file in..." (no dollar here, but one's needed when dereferencing)

Superstoned
08-28-2003, 12:58 PM
aaah, tnx, I'm trying it now...

Superstoned
08-28-2003, 01:05 PM
and it doesnt seem to work, although it comes closer. but now i get errors like

fopen: ./Bands/klassiek/09: id3v2: No such file or directory
fopen: -: id3v2: No such file or directory
fopen: The: id3v2: No such file or directory
fopen: Blue: id3v2: No such file or directory
fopen: Danube.mpc: id3v2: No such file or directory

looks like the directory's (and long filenames) are the problem?!?

command was:
for file in $( find -name '*.mpc' ) ; do id3v2 -d $file ; done
I tried to put the $file this way: '$file'. but that returned
fopen: $file: id3v2: No such file or directory


and im goin' now, for some days, so - ill check back later (next week). tnx for all the help and advice!

baldyeti
08-28-2003, 01:55 PM
looks like the directory's (and long filenames) are the problem?!?
Indeed embedded spaces seem to interfere; try

id3v2 -d \"$file\"

Cheers,

bald.

Dave_Bechtel
08-29-2003, 01:41 AM
--Here's a couple of more things you can try adapting to work with the ' find ' command: (NOTE: Case-conversion commands generally don't work on FAT32 - it thinks it's the same exact filename. Copy the files to a Linux filesystem like ext2 or reiserfs if you want them case-translated.)

# cvt all fnames to locase:

for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done

# cvt spaces to dashes

for i in *.mp3; do mv "$i" `echo $i | tr ' ' '-'`; done

# cvt to std extensions - another way

for i in *.MP3; do mv "$i" "`basename "$i" .MP3`.mp3"; done


and it doesnt seem to work, although it comes closer. but now i get errors like

fopen: ./Bands/klassiek/09: id3v2: No such file or directory
fopen: -: id3v2: No such file or directory
fopen: The: id3v2: No such file or directory
fopen: Blue: id3v2: No such file or directory
fopen: Danube.mpc: id3v2: No such file or directory

looks like the directory's (and long filenames) are the problem?!?

command was:
for file in $( find -name '*.mpc' ) ; do id3v2 -d $file ; done
I tried to put the $file this way: '$file'. but that returned
fopen: $file: id3v2: No such file or directory


and im goin' now, for some days, so - ill check back later (next week). tnx for all the help and advice!

Superstoned
09-01-2003, 12:44 PM
hmmm, sorry i didnt reply earlier. thought I posted, but I think I forgot to press submit...

I've been on a festival for some days
got sick
so im back home...

anyway, I still haven't made it.

when I give the following line:

for file in $( find -name '*.mpc' ) ; do id3v2 -d $file ; done

I get:
(...)
fopen: ./Overig/Cypress: id3v2: No such file or directory
fopen: Hill/III: id3v2: No such file or directory
fopen: (Temples: id3v2: No such file or directory
fopen: of: id3v2: No such file or directory
fopen: Boom)/Cypress: id3v2: No such file or directory
fopen: Hill: id3v2: No such file or directory
fopen: -: id3v2: No such file or directory
fopen: 13: id3v2: No such file or directory
fopen: -: id3v2: No such file or directory
fopen: Strictly: id3v2: No such file or directory
fopen: Hip: id3v2: No such file or directory
fopen: Hop.mpc: id3v2: No such file or directory
(...)

there seems to be a problem with the spaces somewhere?

I tried:
for file in $( find -name '*.mpc' ) ; do id3v2 -d '$file' ; done

but I got:
(...)
fopen: $file: id3v2: No such file or directory
fopen: $file: id3v2: No such file or directory
fopen: $file: id3v2: No such file or directory
fopen: $file: id3v2: No such file or directory
fopen: $file: id3v2: No such file or directory
(...)

Dave_Bechtel
09-01-2003, 08:24 PM
--You might want to pick up the O'Reilly book on Bash shell programming. ;-) It's been an invaluable help to me. When you put single-ticks around '$file' it doesn't go thru expansion/translation.

--Anyway, you can try something like this: (Note, the font may be bad, so to clarify - these are CURLY brackets - the shifted ones.) This command, when executed from the root directory (/) will list all the symlinks on your system.


find / -type 'l' -name '*' -exec /bin/ls -l "{}" ";"


--Morphed to your needs (but only mildly tested)


find -name "*.mpc" -exec id3v2 -d "{}" ";"


--From ' man find ':

-exec command ;
Execute command; true if 0 status is returned. All following
arguments to find are taken to be arguments to the command until
an argument consisting of `;' is encountered. The string `{}'
is replaced by the current file name being processed everywhere
it occurs in the arguments to the command, not just in arguments
where it is alone, as in some versions of find. Both of these
constructions might need to be escaped (with a `\') or quoted to
protect them from expansion by the shell. The command is exe-
cuted in the starting directory.


--Another short example:


# ===== Find all symlinks and keep a list for later
echo ' *** Finding all symlinks... '

# Methodology for this taken from ' info tar ' somewhere
# -mount = Don't descend into other filesystems
# -print0 seps with NULL char instead of LF

find / -type 'l' -name '*' -mount -print0 > /Allsymlinks.NULLlist

echo ' *** Backing up all symlinks *** '
tar -cvz --null --files-from=/Allsymlinks.NULLlist --file=$Bkpdir/SYMLINKS.tar.gz


--Note: If you " echo * ", you don't get what you expect. (Type that in w/o the quotes.) Messed up my debugging scripts something awful until I looked it up, now I always put wildcards in single-ticks if I want them displayed as part of a banner. :)


hmmm, sorry i didnt reply earlier. thought I posted, but I think I forgot to press submit...

I've been on a festival for some days
got sick
so im back home...

anyway, I still haven't made it.

when I give the following line:

for file in $( find -name '*.mpc' ) ; do id3v2 -d $file ; done

I get:
(...)
fopen: ./Overig/Cypress: id3v2: No such file or directory
fopen: Hill/III: id3v2: No such file or directory
fopen: (Temples: id3v2: No such file or directory
fopen: of: id3v2: No such file or directory
fopen: Boom)/Cypress: id3v2: No such file or directory
fopen: Hill: id3v2: No such file or directory
fopen: -: id3v2: No such file or directory
fopen: 13: id3v2: No such file or directory
fopen: -: id3v2: No such file or directory
fopen: Strictly: id3v2: No such file or directory
fopen: Hip: id3v2: No such file or directory
fopen: Hop.mpc: id3v2: No such file or directory
(...)

there seems to be a problem with the spaces somewhere?

I tried:
for file in $( find -name '*.mpc' ) ; do id3v2 -d '$file' ; done

but I got:
(...)
fopen: $file: id3v2: No such file or directory
fopen: $file: id3v2: No such file or directory
fopen: $file: id3v2: No such file or directory
fopen: $file: id3v2: No such file or directory
fopen: $file: id3v2: No such file or directory
(...)

Superstoned
09-02-2003, 07:56 PM
- it worked
- and I seem to understand it ;-)
- pitty I just did remove the id3v2 tags using tag.exe for winblow$... :p
- anyway, tnx for the help, it is really very much appreciated!


grtz

Jos