Create script file

cowboy

Baseband Member
Messages
91
Anyone able to help.





Looking to create a script file that will;


append a file "xxxx" with yyy, so the result will be "xxxxyyy"


Looking to do all files in a given directory.....


Thanks
 
to clarify




Anyone able to help.

Looking to create a script file that will append all files in a given Dir.;

all files would retain initial name with "yyy"appended to them

Looking to do all files in a given directory.....

Thanks
 
Anyone able to help.





Looking to create a script file that will;


append a file "xxxx" with yyy, so the result will be "xxxxyyy"


Looking to do all files in a given directory.....


Thanks


# "Get-Childitem" - get files and directories.
# "-recurse" - look within each subfolder too, remove if you dont need.
# "C:\Users\username\" - change to the directory you want to use.
# "Where-Object {$_.PSIsContainer -eq $false}" - will exclude directories (folders from the list, otherwise you will rename the folders too).
# "Rename-Item -NewName" - this is the cmdlet that will change the name of the file.
# "$_.Name" This will prepend the original file name.
# "yyyy" - This is what you want to append to the file name, change as you please.
# "$_.Extension" - This will append the file extension onto the file name.

get-childitem -recurse "C:\Users\Username\test" | Where-Object {$_.PSIsContainer -eq $false} | Rename-Item -NewName {$_.Name + "yyyy" + $_.Extension}


Hope that makes sense, BEWARE THIS WILL CHANGE ALL FILE NAMES in the directory you specify and sub directories within.
 
its Powershell.exe

If you want to save as a script, save as "rename_files.ps1"

then you can edit what you need and right-click it to run, or use in a task.

Ive used # before each sentence, as it means comment. so you can leave that in your script as references if you need.

its just a 1 liner.
 
Last edited:
Back
Top Bottom