Jump to content

Batch - Rename folders

Go to solution Solved by xc3ll,

Ok, this was easy.

For the record:

'rename "old" "new" ' works perfectly - Sometimes the solution is pretty obvious. Can't find it on google though...

Hello Guys,

 

I'm working on a little back-up script in batch, which daily copies Data from selected folders to a backup Drive. It creates n folders, like 1DayAgo, 2DaysAgo ... nDaysAgo. So every day all files and folders from nDaysAgo have to be moved to n+1DaysAgo. At the moment I use Robocopy -move, but this creates a lot of unnecessary overhead.

 

It would be much faster, if I could just rename the folders. For example (in pseudo-code):

Delete folder n;

rename n-1 to n;

rename n-2 to n-1;

.....

 

Does anyone know a command to this (It has to work on Win7)? Google (to be hones: Duckduckgo) wasn't in the mood of telling me :(

Ryzen 5 5600, 32GB DDR4, GTX 3070Ti, Acer Predator x34

InWin 901

Link to comment
https://linustechtips.com/topic/203154-batch-rename-folders/
Share on other sites

Link to post
Share on other sites

Thank you, but this is exactly what robocopy -move does: It creates a new folder, copies all Data into it and deletes it.

I'm looking for a way without moving/copying Data, cause that would be much faster.

Ryzen 5 5600, 32GB DDR4, GTX 3070Ti, Acer Predator x34

InWin 901

Link to comment
https://linustechtips.com/topic/203154-batch-rename-folders/#findComment-2757743
Share on other sites

Link to post
Share on other sites

Of course i wanna keep my data :)

I use xcopy to create a backup folder, just like you do. But, i wanna keep a "History" of 5Days. So I create, hard coded, folders like 1DayAgo etc...

Now i have to copy all my Data from folder n to n+1 etc. This takes lots of time, since i have to copy all my data 5 times.

It would be nice if i could just change the name of the folders instead.

 

In pseudo code:

 

for(n=5; n > 1; n--)

Delete n Days Ago; #

copy n-1DaysAgo to nDaysAgo; #Here i wanna rename instead of copying

 

create Backup to 1DaysAgo;

 

It's all working but with the copy command it takes really long...

Ryzen 5 5600, 32GB DDR4, GTX 3070Ti, Acer Predator x34

InWin 901

Link to comment
https://linustechtips.com/topic/203154-batch-rename-folders/#findComment-2757968
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×