0

I have file names like:

A_20141001_20141224.txt
A_20141002_20141224.txt
B_20141001_20141224.txt
B_20141002_20141224.txt
C_20141001_20141224.txt
C_20141002_20141224.txt

I want to rename them to:

A_20141001_20141224.txt.20141001000000
A_20141002_20141224.txt.20141002000000
.....

Can I achieve this using PowerShell?

I couldn't find answers which picks an item in the existing file and appends it as the suffix to the file.

0

1 Answer 1

0

Use the below bat and it works fine in our environment for your scenario

SETLOCAL EnableExtensions EnableDelayedExpansion
FOR %%I IN (*.txt) DO (
    SET NAME=%%~nI
    RENAME %%I %%I.2014100!NAME:~9,1!000000
)
ENDLOCAL
1
  • Thanks this works for these files. Is there any way if we can specify the count from the first occurrence of the '_' as file names are all of not same length. Dec 25, 2014 at 7:21

Not the answer you're looking for? Browse other questions tagged .