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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
technotika
Posts: 10
Joined: 02 Jun 2011 06:22

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

#1 Post by technotika » 11 Jan 2012 05:18

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.

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

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

#2 Post by orange_batch » 11 Jan 2012 06:27

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.

technotika
Posts: 10
Joined: 02 Jun 2011 06:22

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

#3 Post by technotika » 11 Jan 2012 06:38

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

Post Reply