Find Files By Name Format

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
RNIB
Macro Veteran
Posts: 173
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Find Files By Name Format

Post by RNIB » Tue Jul 16, 2024 8:40 am

I have a drive with other 5000 folders on it.

Each folder either consists of files or 2 or more sub folders. If there are sub folders it is these that will contain files.

The files in the folders will be a mix of formats but will always contain MP3 files

These MP3 files will be named in one of two ways. I need to be able to identify the name of the folder that contains files that are named in a specific way. Initially I believed that the files I needed to identify always had the folder name as part of the file name and so this was my code:

Currently I have a version working as follows:

Code: Select all

Let>INPUT_BROWSE=2
Input>folder_result,Please Select The Root Folder,
IF>folder_result=
Exit>0
EndIF
Let>GFL_TYPE=1
Let>GFL_SORTTYPE=3
GetFileList>%folder_result%\*.*,folders
Separate>folders,;,folder_names
Let>k=0
Label>Start
Repeat>k
Let>k=k+1
ExtractFileName>folder_names_%k%,name_folder
Wait>0.2
ChangeDirectory>%folder_result%\%name_folder%\
CountFiles>%name_folder%*.mp3,nCount,0
If>nCount>0
PutClipBoard>%name_folder%
Wait>0.2
SetFocus>renamed_titles.txt - Notepad
Wait>0.2
Press>Ctrl
Send>v
Release>Ctrl
Press>Enter
Press>Ctrl
Send>s
Release>Ctrl
EndIf
GoTo>Start
Until>k=folder_names_count
However, subsequently I've found that this is not always the case. However, I've confirmed that the naming convention I need to identify is always presented as:

6 digits_0_4digitsa_Text
e.g
024002_0_0001a_RipTide

The value of the 6 digits will be different in each folder but will be the same for all MP3 files within a folder. The 4 digit number will start at 0001 and will increment by 1 for each MP3 file and is always followed by the letter a. The text at the end will be different in each folder. Overall the file name length will vary from folder to folder but that will be defined by the length to the Text at the end the 6digits_0_4digitsa_ is always the same.

I'm currently trying to work out how I can make the code check for that 6digit_0_4digita_ file name but I don't really know where to begin. I also eventually need it to check for subfolders but that can wait until I've solved this first issue.

RNIB
Macro Veteran
Posts: 173
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Re: Find Files By Name Format

Post by RNIB » Tue Jul 16, 2024 8:59 am

Hmm, okay, well changing the CountFiles to:

CountFiles>******_0_****a_*.mp3,nCount,0

Seems to do the job. I didn't think it would be as simple as that :roll:

So how would I amend this to look inside sub folders?

The folders on the root will either contain just files or just sub folders, never a combination of the two.
If there are subfolders there will always be at least two but it could be more. There isn't a guarantee that the subfolders will be named in a consistent manner.

If there are two or more subfolders, the macro only really needs to check 1 of them because if the MP3 files are named using the 6digit_0_4digita_text format in one then they would be in the others as well. When it check the sub folders I need it to give me the name of the root folder.

RNIB
Macro Veteran
Posts: 173
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Re: Find Files By Name Format

Post by RNIB » Tue Jul 16, 2024 1:02 pm

Solved it.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts