and that was the only thing that worked for me.
rename is often an alias to prename, bundled with perl. Show Sample Output
Using a for loop, rename all files with .MP3 extension to .mp3. Show Sample Output
Use it as bash-script. The first positional parameter specifies the fixed length of the numerical index. Further params specify the files to manipulate.
The above command will also rename hidden files or dirs
The 'rename' command with the first argument as "'s/\.//'" and the second argument as "" will remove the specified extension from the filenames.
Given a bunch of files with "wrong" date naming, it renames them in a "good" format. Show Sample Output
I use this on Debian to rename files that exist in directories but do not have the year in the file name. The directory has the year but the files inside don't. How I explain how this runs: The dir variable grabs the name of the folder. Using rename, substitute the name of the first file and remove the extension, then rename it to the directory name. To test this before you run it, change -v to -vn. Show Sample Output
This version works on OS X (if you have installed `rename`)
Music Library Convert Usage lc Old_Directory New_DIrectory Old_Format New_Format lc ~/Music ~/Music_ogg mp3 ogg This will convert all audio files in the old directory to the new directory from the old format to the new format. It will leave the original library alone. The converted library will retain folder structure.
Adding course name prefix to lecture pdfs
Changes files like "temp (2).txt" to "temp.txt". Does not overwrite files that already exist.
# Limited and very hacky wildcard rename # works for rename *.ext *.other # and for rename file.* other.* # but fails for rename file*ext other*other and many more # Might be good to merge this technique with mmv command... mv-helper() { argv="`history 1 | perl -pe 's/^ *[0-9]+ +[^ ]+ //'`" files="`echo \"$argv\"|sed -e \"s/ .*//\"`" str="`history 1 | perl -pe 's/^ *[0-9]+ +[^ ]+ //' | tr -d \*`" set -- $str for file in $files do echo mv $file `echo $file|sed -e "s/$1/$2/"` mv $file `echo $file|sed -e "s/$1/$2/"` done } alias rename='mv-helper #'
of course, replace the "-" after / by the character you wish. a dot must by protected by a backslash, as it is a regexp. it's the same result as the command proposed. but if there is more than a dash in the name, only the part before the first dash is kept... so that's not an "extension renaming" command.
rename command in my system -Fuduntu running 2.6.38 Linux Kernel- is an ELF 64-bit LSB executable, not a Perl script. man page for rename command shows syntax as "rename from to where" (or something like that), so I am doing just what I have been told... Show Sample Output
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: