Page 1 of 1

I want to create a batch file (.bat) that changes [file name

Posted: 25 Jul 2010 03:35
by Pongy
Dear Master Batch Programmers,

Here's the dealio: many software applications come without an auto-save function. I'm flabbergasted. Flabbergasted I say. Excel, Propellerhead Reason, simple apps like Wavosaur... No auto-save! I don't get it. Been thinking about it and I still don't get it. It seems like such a basic function that should be standard in all apps, especially very popular ones such as Excel. Well Excel's got auto-save but it doesn't work the way I want it. And Reason and Wavosaur don't have auto-save at all. Music creativity tools without auto-save... I rest my case. I love both of them but god bless their souls I'm clueless as to this issue.

Alright, 'nuf said about that. Let's create a tool for this. C'mon we can do it.

I've figured out the following solution. Let's create a batch file (.bat) that changes [file name] in a given folder to [date]+[file name], waits 10 seconds and then loops. In that way, every time a file is saved to the folder it will be renamed and thus make place for a new file.

I hope you're following. Let's clarify and summarize:

The batch script is running until turned off by the user. When a file is added to a specific folder the script renames the file name from e.g. save.rsn to 1007181053save.rsn [YYMMDDMMSS]. The script waits for 10 seconds then checks the folder again and renames any hitherto unrenamed files.

Help me out here oh master programmers!

Kind regards

Pongy

Re: I want to create a batch file (.bat) that changes [file

Posted: 25 Jul 2010 12:54
by aGerman
Funny things.
Did you ever try to make that by hand? E.g. an Excel file is protected if it is opened. You can't rename it or something else. And if you didn't save your documents then a copy of this document will not contain your changes!
No idea what this could be good for ....

Regards
aGerman

Re: I want to create a batch file (.bat) that changes [file

Posted: 25 Jul 2010 13:05
by Pongy
I have no idea what your comment is good for either, please refrain from commenting on my posts again.

Re: I want to create a batch file (.bat) that changes [file

Posted: 25 Jul 2010 22:34
by phillid
No need to be so harsh on aGerman. :cry:
I think I get the drift of what you are attempting to do. You could make a copy of the document, name it [date][filename] and overwrite it every N minutes with an updated copy. But as aGerman said, you would have to save the document every so often for the copy to be up-to-date. I have tried putting the date and time into a filename, but they both contain illegal characters. The date has / and the time has : It would only require a simple FOR loop to filter these characters out.

phillid

Re: I want to create a batch file (.bat) that changes [file

Posted: 26 Jul 2010 04:26
by miskox
I agree with phillid.

aGerman was not doing anything wrong. He just warns against the 'file locked' conflict.

Saso