GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Unix gurus, how do you batch rename multiple folders (https://gfy.com/showthread.php?t=1055657)

Just Alex 01-31-2012 11:36 AM

Unix gurus, how do you batch rename multiple folders
 
Lets say I have them 001, 002, 003 .. etc.. How can I rename them 200,201,202 or just do 1-001, 1-002, 1-003

Anyone knows a command or script?

MaDalton 01-31-2012 11:49 AM

i use total commander via ftp

gleem 01-31-2012 11:51 AM

I used this to rename extensions, should work on folders too:

http://lab.artlung.com/unix-batch-file-rename/

just replace the "00" part with "200"

raymor 01-31-2012 11:56 AM

Check out "man rename". An example

rename 'foo' 'bar' dir*

dir_foo1/ becomes dir_bar1/
dir_foo2/ becomes dir_bar2/

Quote:

Originally Posted by Just Alex (Post 18723611)
Lets say I have them 001, 002, 003 .. etc.. How can I rename them ... 1-001, 1-002, 1-003

For that specifically:
rename "" "1-" 0*

Just Alex 01-31-2012 12:48 PM

Thanks guys

fris 01-31-2012 01:13 PM

if you wanted to renaming inside the folders for say imagesr like akjs.jpg bigpacks.jpg etc and rename them to 1.jpg 2.jpg 3.jpg.

Code:

#!/bin/bash

i=1;
shopt -s nullglob;

for f in *.{jpg,jpeg,JPG,JPEG,gif,GIF,png,PNG}; do   
        ext="${f##*.}";
        ext=${ext,,};
        ext=${ext/jpeg/jpg};   
        mv -- "$f" "newfolder/$i.${ext}";   
        ((i++));
done



All times are GMT -7. The time now is 12:51 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc