# DOS 指令 ###### tags: `DOS語法` ### 情境: 單一 Folder 下又有很多小Folder,每個小 Folder 又有各自的 CSV 檔案,要根據每個小 Folder 檔名帶有的日期去做截取,然後拿來做更改小 Folder 檔名用。 ``` $folder_path = "C:\Users\andy_chen\Desktop\TEST" $path = get-childitem -path $folder_path foreach ($folder in $path) { $new_folder_path = $folder $new_path = get-childitem -path $new_folder_path foreach ($file in $new_path){ $time = $folder.name $time = $time.substring($time.IndexOf("_"), 9) $newFileName = $file.BaseName + $time +".txt" Rename-Item $file.FullName $newFileName } } ``` 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up