开发者

Batch - Generating File Names

开发者 https://www.devze.com 2023-04-10 19:08 出处:网络
I looked up my question on the Intern开发者_如何学编程et but couldn\'t find an answer...so I\'m posting it here.

I looked up my question on the Intern开发者_如何学编程et but couldn't find an answer...so I'm posting it here.

I want my batch to creat a folder with the name of most recent folder +1. For example I have a folder called "folder-01" and I want the batch to call it "folder-02".

Then I want it to create a .html file named after the most recent file (that is in the most recent folder) +1; For example I have a file called "test-01.html" located in "folder-01" and I want it to create a file called "test-02.html" in "folder-02".

My batch for now looks like this :

@echo off
type Autres\Standart.html > Today\test-02.html
start Programmes\Platform\PortableApps\Notepad++\Notepad++Portable.exe Today\test-02.html
start Programmes\Platform\PortableApps\Firefox\FirefoxPortable.exe Today\test-02.html

The 2nd line in the code is so that my new file is created with a standart html content.

Thx in advance !

--LunaSea


Please have a look at the linux/Posix function mktemp( ). It constructs file names that are guaranteed unique. It could be that you can get mktemp( ) to give you back a file name that increments the way you want it to, but I don't recall that as a mktemp( ) feature.

The main thing is that file name returned is unique, something you cannot guarantee by just blindly bumping the value of the final character. You have to agree that using a file name that you generate is certain disaster if that file name already exists.

0

精彩评论

暂无评论...
验证码 换一张
取 消