Create script file - Techist - Tech Forum

Go Back   Techist - Tech Forum > Computer Software > Microsoft Windows and Software
Click Here to Login
Reply
 
Thread Tools Display Modes
 
Old 05-04-2020, 12:01 PM   #1 (permalink)
Junior Techie
 
Join Date: Jan 2004
Posts: 91
Default Create script file

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
__________________

__________________
cowboy is offline   Reply With Quote
Old 05-04-2020, 12:34 PM   #2 (permalink)
Junior Techie
 
Join Date: Jan 2004
Posts: 91
Default Re: Create script file

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
__________________

__________________
cowboy is offline   Reply With Quote
Old 05-04-2020, 12:42 PM   #3 (permalink)
i2D
i 2 D 2
 
i2D's Avatar
 
Join Date: Jan 2015
Location: Earth
Posts: 1,830
Default Re: Create script file

Quote:
Originally Posted by cowboy View Post
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.
__________________
i2D is offline   Reply With Quote
Old 05-04-2020, 01:32 PM   #4 (permalink)
Junior Techie
 
Join Date: Jan 2004
Posts: 91
Default Re: Create script file

Thank,
what type of file is this ? will it work as a .bat file ?

Thanks
__________________
cowboy is offline   Reply With Quote
Old 05-04-2020, 01:35 PM   #5 (permalink)
i2D
i 2 D 2
 
i2D's Avatar
 
Join Date: Jan 2015
Location: Earth
Posts: 1,830
Default Re: Create script file

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.
__________________
i2D is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Simple Script to Show / Hide File Extensions in Windows XP, Vista and 7 Osiris Tips, Tricks & Tutorials 0 05-28-2010 07:16 AM
Create Simple Script to Show / Hide Hidden Files and Folders in Windows 7 Osiris Tips, Tricks & Tutorials 0 05-28-2010 07:13 AM
Please help me to create simple if and else php script linux1880 Programming 3 08-06-2008 11:42 PM
controlling "change owner to" drop box list in windows using script for a file sangeeta_shetty Microsoft Windows and Software 0 06-17-2008 04:29 AM
file hosting script? lazer_viking ISP and Web Hosting 1 09-08-2006 03:31 AM



All times are GMT -5. The time now is 07:27 AM.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2020, vBulletin Solutions, Inc.