|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
Multiple file rename
hi im new to linux and was just wondering if some 1 could help me
i have folders with T.V. series in them and i would like to delete part of the filename e.g. (series name).s01e01.(episode name) (series name).s01e02.(episode name) (series name).s01e03.(episode name) (series name).s01e04.(episode name) (series name).s01e05.(episode name) i would like them to be s01e01.(episode name) s01e02.(episode name) s01e03.(episode name) s01e04.(episode name) s01e05.(episode name) |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Code:
ls | sed 's/<series name>\.\(.*\)\.\(.*\)/\1.\2/g' | xargs -I% mv '<series name>'.% % |
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Here is my try as well for the entire operation : Position yourself in working folder (series folder) Code:
ls -1 *.avi | sed 's/.*\([Ss][0-9]\{1,2\}[Ee][0-9]\{1,2\}\)\(.*\)/mv "&" "\1\2" /g' # | bashIf you are satisfied with the result pipe it to bash (remove the comment #) It should work with spaces in filenames and any <series name>, condition is that it respects the format S num num E num num Hope that helps Regards Peasant. |
|
#4
|
|||
|
|||
|
Quote:
Since I'm picking nits, the -1 option is never necessary when piping. ls examines its stdout and if it's not the terminal (in this case it's a pipe) it always writes one filename per line. Regards, Alister |
| The Following User Says Thank You to alister For This Useful Post: | ||
Peasant (06-12-2012) | ||
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
Thanks for your information about -1
Considering sed, that's why i suggested the op to inspect the output before running it actually, since it's not a large quantity of files ![]() I presume that quality of code to cover all variants (escape chars, double quotes etc.) would be somewhat bigger then one sed line. Regards Peasant. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Rename multiple file names in a directory | hari001 | Shell Programming and Scripting | 4 | 05-22-2011 04:14 PM |
| For Loop To Rename Multiple Files Finds One Non-existant File | Korn0474 | UNIX for Dummies Questions & Answers | 5 | 11-16-2010 06:41 PM |
| Rename multiple file from file listing | yshahiac | Shell Programming and Scripting | 5 | 02-09-2009 03:42 PM |
| mv command to rename multiple files that retain some portion of the original file nam | grimace15 | Shell Programming and Scripting | 4 | 12-21-2008 05:27 AM |
| Help with multiple file rename - change case of part of file name | steve7 | UNIX for Dummies Questions & Answers | 7 | 06-30-2005 01:41 PM |
|
|