简体   繁体   中英

Rename files, moving date part of name from beginning to end

I have filenames that come with the date at the beginning of their names, eg 20171015….txt .

I currently use a batch file to strip off the first 8 characters and this has worked well. However I'd like to now keep the date but move it to the end of the file name.

With the file name without extension set as a variable, %Variable% :

Ren "%Variable%.ext" "%Variable:~8%%Variable:~,8%.ext"

Or if performed within some sort of loop and delayed expansion enabled, ie SetLocal EnableDelayedExpansion :

Ren "!Variable!.ext" "!Variable:~8!!Variable:~,8!.ext"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM