# Batch file rename

#### torin3

##### Member
I've got a legacy type problem. We switched from using an on-site system to using a managed server for our EDI communication at work. Seems to be working fine in general, except for a filename issue.

We used to get our 830 files named in this format Rxxxxxxx. with the x being hex numbers. Our Access program that updates our databases is set up to use this naming format, and I don't have the skills yet to change it.

The 830 files we are getting from the managed server look like this: 830_ib.EDI_20160924_231249_1442392

I can manually rename the files in about 15 to 20 minutes once a week. But I'd like to automate the process. Can anybody point me to a guide that would let me write a batch/cmd file that would take all 830_ib.x files and rename them in the Rxxxxxxx. style? The exact numbering isn't critical, they just need to not have duplicates and be 0123456789ABCDEF characters, other than the initial R.

Thanks!

#### knoober

##### Member
I've got a legacy type problem. We switched from using an on-site system to using a managed server for our EDI communication at work. Seems to be working fine in general, except for a filename issue.

We used to get our 830 files named in this format Rxxxxxxx. with the x being hex numbers. Our Access program that updates our databases is set up to use this naming format, and I don't have the skills yet to change it.

The 830 files we are getting from the managed server look like this: 830_ib.EDI_20160924_231249_1442392

I can manually rename the files in about 15 to 20 minutes once a week. But I'd like to automate the process. Can anybody point me to a guide that would let me write a batch/cmd file that would take all 830_ib.x files and rename them in the Rxxxxxxx. style? The exact numbering isn't critical, they just need to not have duplicates and be 0123456789ABCDEF characters, other than the initial R.

Thanks!

For Windows (I know this works on Win7 and Win10 but no idea anywhere else) Select all files in the directory > right click the first one and "rename" > select your name and hit Enter. All files will change to the chosen name appended with a number. http://www.howtogeek.com/111859/how...s-in-windows-4-ways-to-rename-multiple-files/ <--- recently had this question myself

For Linux: Lots of stuff out there, pick your poison. I can recommend one if you cant find one you like, as Ive tried 2 or three, but ive run across nearly limitless different ones every time I search.

#### pcgamer4life

##### Member
Assuming you're on Vista, 7, 8, or 10, Powershell can knock this out pretty easily. Batch sucks, stop using it.

Some pseudo-code (don't try to use this, it won't work):
Code:
$files = Get-ChidItem C:\path\to\your\files\*ib.EDI*$counter = 0
for ($file in$files)
{
$newName = "whatever_ib.EDI_${counter}"
Move-Item $file.Name$newName
}
counter++
}

Replies
2
Views
332
Replies
2
Views
358
Replies
1
Views
288
Replies
99
Views
54K
Replies
14
Views
1K