Hey,
How would you move files into a folder that have matching numbers.
Example:
###-folder
file_###.ext
---------------------------
###-folder\file_###.ext
Thanks
Matching Folders and Files Topic is solved
-
- Posts: 7
- Joined: 15 Apr 2017, 15:37
Matching Folders and Files
Last edited by TheTrueKey on 16 Apr 2017, 05:55, edited 5 times in total.
Re: Move files with match into a folder with same match Topic is solved
Hello, I've written a quick script for you that may be useful
I'm not exactly sure what you were asking so let me know if you still need help.
EDIT: updated code
I'm not exactly sure what you were asking so let me know if you still need help.
EDIT: updated code
Code: Select all
dir_input := "tester\folder1" ;change this or add uncomment the fileselectfolder
dir_output := "tester\folder2" ;change to output folder
return
f1::
;FileSelectFolder,dir_input
loop,files,%dir_input%\*.*,R ;looping files from dir_input recursing into folder
{
if RegExMatch(A_LoopFileName,"(\d+)",match) { ;if #####- is found ie nn11(77777-)name.txt
if (strlen(match1) > 4) { ;if found numbers are 5 or higher
numbers := SubStr(match1,strlen(match1)-4) ;put the right five numbers into a variable
IfNotExist,%dir_output%\%numbers% ;if folder not exist, create it
FileCreateDir,%dir_output%\%numbers%
filemove,%A_LoopFileFullPath%,%dir_output%\%numbers%
}
}
}
return
f9::reload
Last edited by Spawnova on 15 Apr 2017, 20:27, edited 2 times in total.
Some of my AHK programs: 3D Voxel Game - Platformer Game
GitHub projects : Image/Pixel scanning class - Direct2D overlay class
GitHub projects : Image/Pixel scanning class - Direct2D overlay class
-
- Posts: 7
- Joined: 15 Apr 2017, 15:37
Re: Move files with match into a folder with same match
Hey Spawn thanks for the reply and script. I thought that might be confusing.
### = random digits
A folder named "###-folder" and any files with the same ### in the name, for example "NN111###-file.ext" get moved to "###-folder".
### = random digits
A folder named "###-folder" and any files with the same ### in the name, for example "NN111###-file.ext" get moved to "###-folder".
Last edited by TheTrueKey on 16 Apr 2017, 06:03, edited 1 time in total.
Re: Move files with match into a folder with same match
Okay, I see now.
Although I'm not sure how your files will be formatted, do you always need only the 5 last numbers?
If so, I've edited the script in my previous post to reflect that.
It will look for a string of numbers larger than 4 (5+) and get the 5 last digits and move the file to that folder, hopefully that helps out.
Although I'm not sure how your files will be formatted, do you always need only the 5 last numbers?
If so, I've edited the script in my previous post to reflect that.
It will look for a string of numbers larger than 4 (5+) and get the 5 last digits and move the file to that folder, hopefully that helps out.
Some of my AHK programs: 3D Voxel Game - Platformer Game
GitHub projects : Image/Pixel scanning class - Direct2D overlay class
GitHub projects : Image/Pixel scanning class - Direct2D overlay class
Who is online
Users browsing this forum: Chunjee, Psych0p4th and 276 guests