Skip to content
WJunction - Webmaster Forum

Batch/Shell script (windows) for remove name from folder help

Status
Not open for further replies.

Gon

Active Member
581
2014
159
I have very basic knowledge about batch/shell script. i googled a bit if there is any tutorial how to remove name from folder , but i could not find any. i have few folder e.g

Random Folder [WJ]
Random Folder 2 [WJ]
Random Folder 3 [WJ]
i want to remove [WJ] from the folder name. it will be really helpful if someone could help me.
 

4 comments

1) Download Bulk Rename Utility (freeware)
2) Right-click in the root folder which contains the folders you want to rename and choose "Bulk Rename Here"
3) Select all the folders you want to rename and in the field "Replace (3)" write:
Replace --> [WJ]
With --> Don't write anything
 
i know there is renamer app available but which i am looking is shell/batch script to do that.
 
.
Post automatically merged:

Code:
#powershell
$folder_path = "C:\Users\Admin\Desktop\temp"
$replace_search = "\[WJ\]" #\ for escaping special chars
$replace_with= ""

#get all obejcts of type directoy
Get-ChildItem -path $folder_path -Directory | % {
    $folder_object = $_
    $folder_path_destination = $folder_object.Parent.FullName + "\" + $folder_object.Name -replace $replace_search,$replace_with
    
    #check if new path different from the old path
    if($folder_object.FullName -ne $folder_path_destination){
        $folder_object | move-Item -Destination $folder_path_destination
    }
}
 
Last edited:
Status
Not open for further replies.

About the author

G
Active Member · Joined
581
Messages
159
Reactions
43
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom