Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Rename Files in a Directory

$
0
0

I have to rename files in a directory that are pictures but use a number as the extension for a card system. The picture numbers are UID's that relate to individuals. I have been trying to do this in a Batch file but getting many errors. The file name look like this

00000.1
00001.2
00123.3
88001.4
12345.7

What i need to do is first strip the "." and change the extension to .JPG

so the first file would be:

000001.jpg

Then strip leading zeros only  so i would end with

1.jpg
12.Jpg
or
880014.jpg

this will be added to a bat file or a ps1 file that Deletes all files from a directory to update with new files renames them then Uploads them to a new location. The first 2 steps and last step i have completed using robocopy. Would rename Item work? or does that only work on current directory. In which case the delete would delete the bat file calling it... Head hurts


Viewing all articles
Browse latest Browse all 6937

Trending Articles