SCRIPT TO MOVE FILES TO SUBDIR
Closed
BennyLod
-
Apr 6, 2010 at 10:17 AM
Richard.Williams Posts 25 Registration date Saturday November 7, 2009 Status Member Last seen July 18, 2012 - Apr 20, 2010 at 10:58 AM
Richard.Williams Posts 25 Registration date Saturday November 7, 2009 Status Member Last seen July 18, 2012 - Apr 20, 2010 at 10:58 AM
Related:
- SCRIPT TO MOVE FILES TO SUBDIR
- How to open msi files on android - Guide
- Forfiles move files older than - Guide
- How to clear recent files in windows 11 - Guide
- How to open rem files without blackberry - Guide
- How to delete multiple files on mac - Guide
2 responses
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Apr 8, 2010 at 10:48 PM
Apr 8, 2010 at 10:48 PM
Dim objFSO Dim objFolder Dim objFile Dim fileName Dim rootPath rootPath = "C:\Data\" 'Set FSO object Set objFSO = CreateObject("Scripting.FileSystemObject") 'Get the folder object associated with the directory Set objFolder = objFSO.GetFolder(rootPath) 'Loop through the Files collection For Each objFile In objFolder.Files fileName = objFile.Name If (InStr(1, fileName, "_FF_") > 0) Then objFSO.MoveFile rootPath & fileName, rootPath & "FF\" ElseIf (InStr(1, fileName, "_FR_") > 0) Then objFSO.MoveFile rootPath & fileName, rootPath & "FR\" End If Next Set objFile = Nothing Set objFolder = Nothing Set objFSO = Nothing
Richard.Williams
Posts
25
Registration date
Saturday November 7, 2009
Status
Member
Last seen
July 18, 2012
14
Apr 20, 2010 at 10:58 AM
Apr 20, 2010 at 10:58 AM
Biterscripting script below. It collects a list of .zip files in C:/data directory. It gets the FF or FR by extracting the text between the first and second underscore (_) in the file name. Then moves the file to that subdirectory.
Copy and paste the script in file C:/Scripts/FFFR.txt, start biterscripting, enter this command.
If need to do this daily, schedule this command in task scheduler.
Don't have biterscripting ? Get it. It's free - good for this stuff. There are several sites to download from. Just google up the word 'biterscripting'.
# Script FFFR.txt var str list, path, file, subdir cd "C:/data" lf -n "*.zip" > $list while ($list <> "") do lex "1" $list > $path stex -p "^/^l[" $path > $file stex -p "^_^[" $file > $subdir ; stex "[^_^" $subdir > null # $subdir now has FF or FR. system move ("\""+$path+"\"") ("\""+$subdir+"\"") done
Copy and paste the script in file C:/Scripts/FFFR.txt, start biterscripting, enter this command.
script "C:/Scripts/FFFR.txt"
If need to do this daily, schedule this command in task scheduler.
"C:/biterscripting/biterscripting.exe" "C:/Scripts/FFFR.txt"
Don't have biterscripting ? Get it. It's free - good for this stuff. There are several sites to download from. Just google up the word 'biterscripting'.