hi, I'm pretty new to AHK and having a hard time putting together the pieces after reading some of the related topics.
could any one please help me solve this?
I have a folder on C: drive called "Main"; and there are many (hundreds) subfolders inside that folder. And each of those subfolders has a few files (only files, no subfolder) within them.
I'm trying to create a script that would one by one go through each subfolder in c:\Main\****:
1. MOVE all the files in each of those subfolders to the root folder of my D drive (D:\)
2. immediately delete that subfolder in which all the files were moved, and move on to the next subfolder
thank you very much in advance
Moving files from subfolders
Re: Moving files from subfolders
an example
move from SOURCE\subfolder to DESTINATION ( without subfolder)
move from SOURCE\subfolder to DESTINATION ( without subfolder)
Code: Select all
;---- Filemove and delete empty Folder
/*
;https://autohotkey.com/boards/viewtopic.php?f=5&t=31220
I'm trying to create a script that would one by one go through each subfolder in c:\Main\****:
1. MOVE all the files in each of those subfolders to the root folder of my D drive (D:\)
2. immediately delete that subfolder in which all the files were moved, and move on to the next subfolder
*/
;- NOTE : this script does'nt create Folders/SubFolders in DESTINATION (dest) and doesn't remove SOURCE-folder
; maybe use errorlevel for files with same name
;- be careful with move , test it before use with TEST FOLDERS
;___________________________________________________________________________________
;extensions:="mp3,mp4"
source=%a_desktop%\TEST1 ;- FROM
dest =%a_desktop%\TEST2 ;- TO
ifnotexist,%dest%
filecreatedir,%dest%
i=0
;goto,part2
Loop,%source%\*.*,0,1
{
ALF= %A_LoopFileFullPath%
SplitPath,alf, name, dir, ext, name_no_ext, drive
;If ext in %Extensions%
{
i++
filemove,%alf%,%dest%\%name%
}
}
if (i=0)
{
msgbox, No files found
exitapp
}
;return
;--------------------------
PART2:
e1x:=""
DelFolderCount := 0
DelErrorCount := 0
Loop, %source%\*.*, 2, 1
{
counter := 0
Loop, %A_LoopFileFullPath%\*.*, 0, 1
counter++
if counter = 0
{
e1x .= A_LoopFileFullPath . "`r`n"
DelFolderCount++
}
}
sort,e1x,R ;- show first sub\sub directories
;-
if (DelFolderCount>0)
{
msgbox, 262180,Folders Delete,%e1x%`n %DelFolderCount% empty folders. (%DelErrorCount% errors.)`nWant you really delete these empty Folders ?
ifmsgbox,NO
exitapp
Loop, Parse,e1x, `n, `r
{
T:= A_LoopField
if t=
continue
msgbox, 262180,Folder Delete,Want you really delete this empty Folder ?`n%t%
ifmsgbox,NO
continue
fileremovedir,%t%
}
}
if (i>0)
run,%dest%
exitapp
;================== END-script =====================================================
Re: Moving files from subfolders
Thank you Garry, I'll try this. will give you update. really appreciate your help
Who is online
Users browsing this forum: boydfields and 153 guests