Jump to content

Recommended Posts

Posted

Hi, I want to make a batch script which takes a file name which comes in this format:

MonthDayYearHoursMinutesSecondsAM/PM.pdf

and renames it to

YearMonthDayHoursMinutesSecondsAM/PM.pdf

For example:

09302008092212AM.pdf -> 20080930092212AM.pdf

I am hoping I can use the for command to do this somehow. Maybe someone can tell me if I can use "2 characters" as a delimeter, that way I could split it into 09 30 20 08 09 22 12 AM .p df and rearrange.

Any help would be highly appreciated,

Thanks


Posted

Here's an example of variable expansion, (see SET /?), which should help you out!

@Echo off&Setlocal
Set "_=09302008092212AM.pdf"
Set "_=%_:~4,4%%_:~0,4%%_:~8%"
Echo:%_%&Pause

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...