I'm trying to add the 2nd root directory name to all files, in all preceding subfolders
ie grab a list of the directory names in a root directory ie all the top level directories in the root directory
ie under directory apples theres 3 directories labelled a1 b2 c3
I then want all the files in all subdirectories under a1 to be labelled as a1 apples.wav & all the files in all subdirectories under b2 to be labelled as b2 asdf.wav etc
Add Directory Name To All Files In All Subdirectories
Re: Add Directory Name To All Files In All Subdirectories
Code: Select all
FileSelectFolder, MyFolder
Loop, % MyFolder "\*", 2, 0 ; 2 = Only folders are retrieved (no files).
{
;MsgBox, % A_LoopFileName "`n" A_LoopFileLongPath
CurrentFolder := A_LoopFileName
Loop, % A_LoopFileLongPath "\*", 1, 0 ; 1 = All files and folders that match the wildcard pattern are retrieved.
{
SplitPath, A_LoopFileLongPath, OutFileName, OutDir
FileMove, % A_LoopFileLongPath, % OutDir "\" CurrentFolder " " OutFileName
;MsgBox, % OutDir "\" CurrentFolder " " OutFileName
}
}
return
Re: Add Directory Name To All Files In All Subdirectories
Thats a great example thnx
I modified the script to read only the top directories, I just need to know how to prefix the directory name to all the files in a directory
thnx
I modified the script to read only the top directories, I just need to know how to prefix the directory name to all the files in a directory
thnx
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
MyFolder = D:\s
Loop, % MyFolder "\*", 2, 0 ; 2 = Only folders are retrieved (no files).
{
;MsgBox, %A_LoopFileLongPath%
CurrentFolder := A_LoopFileName
MsgBox, %CurrentFolder%
}
return
Re: Add Directory Name To All Files In All Subdirectories
Roonyroo wrote:I just need to know how to prefix the directory name to all the files in a directory
Code: Select all
; Renames all the files in the selected folder to include the folder name
; Does not recurse (go deeper) into child folders
FileSelectFolder, MyFolder ; Select a folder
SplitPath, MyFolder, FolderName ; Get the folder name
Loop, % MyFolder "\*", 0 ; 0 = (default) Folders are not retrieved (only files).
{
FileMove, % A_LoopFileLongPath, % MyFolder "\" FolderName " " A_LoopFileName
MsgBox, % MyFolder "\" FolderName " " A_LoopFileName
}
return
Re: Add Directory Name To All Files In All Subdirectories
Brilliant ...
I tried the following but I keep getting s10871115145424835001gte065_UG_e-guitar 1_d#_1.wav
instead of D:\s\1087\1115\1454\248\350\1087gte065_UG_e-guitar 1_d#_1.wav
I tried the following but I keep getting s10871115145424835001gte065_UG_e-guitar 1_d#_1.wav
instead of D:\s\1087\1115\1454\248\350\1087gte065_UG_e-guitar 1_d#_1.wav
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
MyFolder = D:\s
Loop, % MyFolder "\*", 2, 0 ; 2 = Only folders are retrieved (no files). 0 dont recurse into subfolders
{
;MsgBox, %A_LoopFileLongPath%
x1:=A_LoopFileLongPath
CurrentFolder :=A_LoopFileName
;MsgBox, %CurrentFolder%
Loop, % A_LoopFileLongPath "\*", 0, 1 ; 1= Only files are retrieved (no files). 1 recurse into
subfolders
{
x:=A_LoopFileLongPath
xs:=A_LoopFileName
xsl = %A_LoopFileDir%\%currentfolder%%xs%
clipboard = %xsl%
FileMove, %x%, %xsl%
msgbox %xsl% %A_LoopFileDir% x = %x%
}
}
return
esc::exitapp
Who is online
Users browsing this forum: madensuyu1, peter_ahk and 355 guests