I have around 60,000 folders that I need to find out a range of info about and produce me a 'report' detailing this info. I need to find out:
- If a folder contains sub folders and if so how many
- Get a list of all of the sub folder names
- Find out if one of the subfolders is named "regenerated"
- If there aren't any subfolders or if there are but one of them is called "regenerated", get a list of the MP3 files in that folder and see if the file name is longer than 8 characters.
- If there are subfolders and one isn't called "regenerated", go into the sub folder and get a list of the MP3 files and see if the file name is longer than 8 characters.
- Then capture an example of how the MP3 files are named
- Then enter the following information into a report (eventually I want to use Excel but currently testing with Word). For each folder it should present the following on one line:
Name of Parent folder
Name of Drive it's on
If it contains subfolders (Y/N)
The names of all the subfolders
If the MP3 file name is longer than 8 characters (Y/N)
The name of one of the MP3 files
Code: Select all
Let>Data=Data4
Let>folder_result=C:\Users\OJohnson\OneDrive - RNIB\Desktop\%data%
//Set path to spreadsheet
//Let>Spreadsheet=C:\Users\OJohnson\OneDrive - RNIB\Desktop\Files_in_TB_Library.xlsx
//Record the Data Partition in Spreadsheet
Let>SheetData=%Data%
//Get Folder Names in Root of Directory
Let>GFL_TYPE=1
Let>GFL_SORTTYPE=3
GetFileList>%folder_result%\*.*,folders
Separate>folders,;,folder_names
//Extract Each Folder Name in Root of Directory
Let>k=0
Repeat>k
Let>k=k+1
Let>Regen=0
ExtractFileName>folder_names_%k%,name_folder
//Change to the next folder in Root
ChangeDirectory>%folder_result%\%name_folder%\
//Check for subfolders
CountDirs>%folder_result%\%name_folder%\,SubCount,0
Let>SheetSFCount=No
Let>sub_folder_name_each=" "
If>SubCount>0
Let>SheetSFCount=Yes
GoSub>Get_Sub_Folder_Names
Endif
GoSub>Count_File_Name
SRT>Get_Sub_Folder_Names
Let>GFL_TYPE=1
Let>GFL_SORTTYPE=3
GetFileList>%folder_result%\%name_folder%\*.*,subfolders
Separate>subfolders,;,sub_folder_names
Let>n=0
Repeat>n
Let>n=n+1
ExtractFileName>sub_folder_names_%n%,sub_folder_name_each
//Record Names of Subfolders in Spreadsheet
Let>SheetSubNames=sub_folder_name_each
Until>n=SubCount
GoSub>Check_For_Regenerated
END>Get_Sub_Folder_Names
//Regen state: 0=default & no sub folders 1=Sub folder present and IS named regenerated 2=Sub folder present NOT named regenerated
SRT>Check_For_Regenerated
Let>GFL_TYPE=1
Let>GFL_SORTTYPE=3
GetFileList>%folder_result%\%name_folder%\*.*,subfolders_regen
Separate>subfolders_regen,;,sub_folder_names_regen
Let>y=0
Repeat>y
Let>y=y+1
ExtractFileName>sub_folder_names_regen_%y%,sub_name_folder_regen
If>sub_name_folder_regen=regenerated
Let>Regen=1
GoSub>Count_File_Name
Else
Let>Regen=2
GoSub>Select_Folder
Until>y=SubCount
Endif
END>Check_For_Regenerated
SRT>Select_Folder
ChangeDirectory>%folder_result%\%name_folder%\%sub_name_folder_regen%\
GoSub>Count_File_Name
END>Select_Folder
//Counts the number of characters in an MP3 file name
SRT>Count_File_Name
Let>GFL_TYPE=0
If>Regen<2
GetFileList>%folder_result%\%name_folder%\*.mp3,mp3namelist
Else
GetFileList>%folder_result%\%name_folder%\%sub_name_folder_regen%\*.mp3,mp3namelist
EndIf
Separate>mp3namelist,;,NamesOfMP3
Let>m=0
Repeat>m
Let>m=m+1
ExtractFileName>NamesOfMP3_%m%,mp3_name
Length>mp3_name,nLength
Until>m=1
GoSub>Write_Spreadsheet
END>Count_File_Name
//SRT>Check_Files
//needs to 6digit_1digit_4digita_ the 6 digit is the TB number, 1 digit is disc number, 4 digit is running order
//GetFileList>%folder_result%\%name_folder%\%sub_name_folder%\*.mp3,mp3namelist
//Separate>mp3namelist,;,NamesOfMP3
//ExtractFileName>NamesOfMP3_1,mp3_name
//Record MP3 file name in spreadsheet
//Let>SheetMP3Name=mp3_name
//GoSub>Write_Spreadsheet
//END>Check_Files
SRT>Write_Spreadsheet
SetFocus>TB Library Analyasis.docx - Word
Send>%name_folder%
Press Tab *2
Release Tab
Send>%data%
Press Tab
Release Tab
Send>%SheetSFCount%
Press Tab *2
Release Tab
Send>%sub_folder_name_each%
Press Tab *2
Release Tab
If>nLength>12
Send>Yes
Else
Send>No
Endif
Press Tab *4
Release Tab
Send>%mp3_name%
Press Enter
Release Enter
END>Write_Spreadsheet
Until>k=folder_names_count
I think I need to concatenate the sub folder names but I can't work out how to do that within a loop.