Page 1 of 1

find a file, rename it, then rename back again...

Posted: 11 Jan 2012 05:18
by technotika
Hi Guys

Just hoping to see if this is possible in batch.....

I run a "clean up script" that does various things, cleans junk, runs cmd line defrag util, also a piece of freeware that deletes
tmp files.
However its come to light that two files with extentions of .tmp & .bak are being removed which are causing issues with some
software.
The clean up util has no way of setting exceptions (cant find another cmd tool either with it) so i was hoping to set a command
to find the files, rename them, then have the clean up part of the script run then have another command to run to find them again and rename them back.

If there any example scripts to try with that would be excellent.

Thanks in advance.

Re: find a file, rename it, then rename back again...

Posted: 11 Jan 2012 06:27
by orange_batch
A better option would be to write an exception in the clean-up script for those particular files.

Otherwise, the process goes like...

ren file1.tmp file1.tmp.dat
ren file2.bak file2.bak.dat

*script runs*

ren file1.tmp.dat file1.tmp
ren file2.bak.dat file2.bak

ren has the syntax: ren source new_name

Where source is an absolute or relative path, and name is the new name only.

Re: find a file, rename it, then rename back again...

Posted: 11 Jan 2012 06:38
by technotika
Problem being the file can reside in any number of sub dirs under a particular root dir. C:\.Marimbatuner\ The files are delivered in channels from a software distribution service on the network and be place in any folder depending the order in which the channels are delivered to the PC's.

So really need so search, rename

## let the clean up part run ##

then rename back

Hope that makes sense

thanks