Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Search for external files possible? (Read 8342 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Search for external files possible?

I would like to have a possibility to create an autoplaylist only from albums, where no external folder.jpg or %artist% - %title%.lrc exists for instance. So i would know which covers i have to scan again or what lyricfiles i have to download still.
Is it possible somehow?

Would be great if i could perform a search like NOT $replace(%path%,%filename_ext%,folder.jpg) PRESENT or something similar.

Any ideas?

EDIT:
Spelling

Search for external files possible?

Reply #1
Sounds like a job for a batch script, although I suck at making batch scripts, so don't ask me.
elevatorladylevitateme

Search for external files possible?

Reply #2
I asked in another forum yesterday to do a search outside foobar2000 and someone wrote this VBScript to me (i modified it a little though):
Code: [Select]
Option Explicit
Dim fso, oApp, oSource, strPath, strFilename
Dim tmpFile, oShell, oFile

Set fso = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
Set oApp = CreateObject("Shell.Application")
Set oSource = oApp.BrowseForFolder(0, "Select folder to add", 22, 12)
  
strPath = oSource.Items().Item().Path
strFilename = InputBox("Please type in filename incl. extension, e.g. 'folder.jpg'","Browse folder","")

If strPath <> "" And strFilename <> "" Then
  Set oFile = fso.CreateTextFile("Result.txt", True)
  GetFolder strPath, strFilename
  oFile.Close
  
  oShell.Run "notepad Result.txt"
End If

Sub GetFolder(strFolder,strFilename)
  Dim oFolder, oFolders, item, strFile
  
  Set oFolder = fso.GetFolder(strFolder)
  Set oFolders = oFolder.SubFolders
      
  For each item in oFolders
    GetFolder item, strFilename
    
    strFile = item.Path + "\" + strFilename
    If Not (fso.FileExists(strFile)) Then 'WScript.Echo "File not available"
      oFile.WriteLine item.Path
    End If
  Next
End Sub


It outputs a list of all folders in a specified direction that hasn't a specified file included in a "result.txt"-file. And it works great.
But i would love to get that directly in foobar2000 without a list of folders but an autoplaylist containing all albums with a missing *.lrc, *.jpg or another specified external file.

I'm not good enough in coding so maybe someone could tell me if and how i could rewrite it to do what i need?
Or could write a plugin for that purpose (or an extension to an existing plugin if its possible)?
I know there are some people who wants this "feature".

Search for external files possible?

Reply #3
can't help with autoplaylist (i think it's not possible) but here is simplified batch code with the same function as your script:

Code: [Select]
FOR /R %%v IN (%1) DO @IF NOT EXIST "%%v" ECHO Not found "%%v" >> result.txt

usage: name it somehow and add variable at the and

for ex. NEX.BAT folder.jpg

Search for external files possible?

Reply #4
Thank you, 2E7AH.
But maybe i miss something, it doesn't work here...

Search for external files possible?

Reply #5
you can tell what you've done, as i can only guess

i remove the pipes to show you how it works on command prompt:


Search for external files possible?

Reply #6
Sorry, for being such a dumb... 
I opened editor, named the file "nex.bat" before inserting your code, copied your code and forgot to paste it in the file... 
Your code works good, thank you.

It simplifies the code but it's not really what i want.

Search for external files possible?

Reply #7
as discussed here, this is vbscript that will accept also a regular expression input as part of the command line argument or manually assigned in
input box:

Code: [Select]
Option Explicit

Dim fso, oApp, oSource, strPath, strFilename
Dim oShell, oFile

Set fso = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
Set oApp = CreateObject("Shell.Application")

If Wscript.Arguments.Count = 0 Then
Set oSource = oApp.BrowseForFolder(0, "Select folder to add", 22, 12)
strPath = oSource.Items().Item().Path
Else
strPath = Wscript.Arguments(0)
If Wscript.Arguments.Count = 2 Then
strFilename = Wscript.Arguments(1)
End If
End If

If strFilename = "" Then
strFilename = InputBox("Please type in filename incl. extension, e.g. 'folder.jpg' (supports regular expresson)","Browse folder","")
End If

If strPath <> "" And strFilename <> "" Then
Set oFile = fso.CreateTextFile("Result.m3u", True)
GetFolder strPath, strFilename
oFile.Close

oShell.Exec("%programfiles%\foobar2000\foobar2000 /command:" & chr(34) & "New Playlist" & chr(34) & " Result.m3u")

End If

Sub GetFolder(strFolder,strFilename)

Dim oFolder, oFolders, oFiles, item
Dim RegularExpressionObject, SearchSubstring, subitem, mark

Set oFolder = fso.GetFolder(strFolder)
Set oFolders = oFolder.SubFolders
Set RegularExpressionObject = New RegExp

With RegularExpressionObject
.Pattern = "(" & strFilename & ")"
.IgnoreCase = True
.Global = False
End With

For each item in oFolders
GetFolder item, strFilename
Set oFiles = item.Files

For Each subitem In oFiles
SearchSubstring = RegularExpressionObject.Test(subitem.Name)
If SearchSubstring Then
mark = 1
End If
Next

If Not mark = 1 And (oFiles.Count > 0) Then
oFile.WriteLine item.Path
End If
Next
Set RegularExpressionObject = nothing
End Sub

search code is different and because of reg exp possibility it's slower (i don't know if somebody will need it but there is other version in linked post).
it works reasonably but the main issue is that if you are searching for missing albumart it may put the whole artist folder in playlist (as it checks only if that folder is empty)
just to say: i'm not in vbscripting, just poking around - so don't expect too much

@ tedgo
i was thinking about the idea of searching for missing lyrics or something like that (search for associated files), and it's not so obvious:

i now where i keep my lyrics and how i name them, but you may have some very different scheme
or maybe you just want to search for some associated files
so the only thing that seems working to me is option with providing playlist:
for example, you'll must save playlist in m3u format (it could be all media playlist or playlist with items that are of your interest) and pass it to the script so it could search for missing files with custom extension according to the items in the playlist
i think that the only drawback in this case would be requirement for saving playlist (which could be done by the script) and not being able to process embedded files like in cue sheets
maybe even easier would be using the output from text tools component, but that is optional component
and maybe there are other options that i'm not aware of, so thoughts are welcomed

Search for external files possible?

Reply #8
Yes, thank you.
With a search option for a regular expression it is easy to find whole albums without a .lrc, .png or .jpg file.
Great, thanks .
The script's getting better and better.

Since foo_run understands titleformatting strings, it would be great if it could accept this:

fooMissingFiles.vbs "D:\Eigene Musik\Alben\" "%artist% - %title%.lrc"

for a missing associated file search.

Would be better if one could type the titleformatting string in the input box though, so it's not necessary to enter a new foo_run preset for different search strings.

The idea to search in a playlist instead of folders for missing associated files is very good. I think, it probably would make it necessary to add an additional checkbox to change behaviour of the script (search for folders, that doesn't contain a file/search for missing associated files in an existing playlist or in specified folders (maybe the Media Library in general)).

EDIT:
Sorry, if i misunderstood your post, but my english is a bit 'rusted' over the years .

Search for external files possible?

Reply #9
hi tedgo, you're always around

did you try some search with reg exp?

fooMissingFiles.vbs "D:\Eigene Musik\Alben\" "%artist% - %title%.lrc"

this would not be possible as you'll get only the result for the selected item in the playlist - that's the foo_run behaviour

but i think this is possible (not quite sure how right now):
Would be better if one could type the titleformatting string in the input box though, so it's not necessary to enter a new foo_run preset for different search strings.

and i'll check that

Search for external files possible?

Reply #10
Thanks for being so busy about my problem
But i think, there are some people who wants this 'feature' (at least there are some on the german foobar-users forum).

Search for external files possible?

Reply #11
hey, it's general problem for anybody that is in need for
and making it more friendly doesn't hurt
the only question is if i'm able to do it

Search for external files possible?

Reply #12
How to get it to work with portable installation?

Search for external files possible?

Reply #13
as mentioned earlier you can't know where is the foobar executable in portable installation, so put the script in foobar's main folder and replace this:

line 29:
Code: [Select]
oShell.Exec("%programfiles%\foobar2000\foobar2000 /command:" & chr(34) & "New Playlist" & chr(34) & " Result.m3u")

with this:
Code: [Select]
oShell.Exec("foobar2000 /command:" & chr(34) & "New Playlist" & chr(34) & " Result.m3u")


one of these days i'll rethink the whole script, so that only one user input will be required (with title formatting, reg exp or simply just filename)

Search for external files possible?

Reply #14
Ok, thanks
There are some one the german board who are very interested on this script.
It's already useful, but has still little room for improvement.
Thanks again for your effort

Search for external files possible?

Reply #15
Is it somehow possible that this script outputs a fpl-playlist instead of m3u?
It seems that its not possible to use it on portabe installation when it outputs a m3u caused by the missing possibility of file association...

Search for external files possible?

Reply #16
no, its not possible. maybe with some other component involved.
but that shouldn't be the problem as the code is changed to start foobar executable (post #14) and not just m3u playlist, so it works in portable mode (i've tried it, just in case)

anyhow i'll put the scripts all together in couple of days because i'm finishing something else right now
also checked about title formating, and that is not possible right now for me, but i'll make possibility of using ID3v1 tags in input box, all together with reg exp and filenames. so that will be in few days

Search for external files possible?

Reply #17
Ok, thanks

But there is someone who has problems to get it working on portable installation.
He said, a blank playlist (fpl) would be created and the 'default' playlist overwritten with the results from the script.
But it would output many wrong results
So i asked about creating a fpl instead of a m3u because i thought it could probably sove his problem.

But i'll see what you'll make out of the script in a few days
Thanks again.

Search for external files possible?

Reply #18
portable foobar is same everywhere: on my computer or at yours

he is using the first script and/or he is doing something wrong (all scripts now create new playlist)

the playlist isn't defined as .fpl or .m3u until you save it, so i guess what blank fpl playlist means

edit: if you have some wrong results you can send them to me of course

Search for external files possible?

Reply #19
I tried it not myself because, i have a standard installation and the script works as intended here.
So i thought it must have been something wrong with portable installation.
I'll say him again how it works and to repeat his trial.
Thanks for your effort

Search for external files possible?

Reply #20
ok, that would be nice

Search for external files possible?

Reply #21
The guy who had problems to get the script working sent me a "test-folder" which imitates his folder structure.
And he's right.
I tried to search for folder.jpg in this test folder and the script failed (hasn't found some entries, listed some entries twice)!

His folder structure is
C:\Library\Genre\Artist\Album\Title and folder.jpg (if existing)
Sometimes:
C:\Library\Genre\Artist\Album\Discnumber\Title and folder.jpg (if existing)

In the first situation some albums without a folder.jpg are not found.
In the second situation there are some files listed twice in the output playlist.

If you send me a PM with you e-mail-adress i could send you this test folder that you can confirm.

Search for external files possible?

Reply #22
is he using the script with regular expressons?

Search for external files possible?

Reply #23
I tried it with his testfolder with regular expression and with full file name.
Failed both times

Search for external files possible?

Reply #24
it's something with the script with reg exp and folder naming (i'll step throught it another time)

the first script (without reg exp), works ok:

Code: [Select]
C:\Tests_1-7\Tests 1-7\Test 1  (es werden Album 1+2 gefunden, Album 7+8 werden nicht gefunden)\Genre\01 Artist_A\01 Album_1
C:\Tests_1-7\Tests 1-7\Test 1  (es werden Album 1+2 gefunden, Album 7+8 werden nicht gefunden)\Genre\01 Artist_A\02 Album_2
C:\Tests_1-7\Tests 1-7\Test 1  (es werden Album 1+2 gefunden, Album 7+8 werden nicht gefunden)\Genre\02 Artist_B\07 Album_7
C:\Tests_1-7\Tests 1-7\Test 1  (es werden Album 1+2 gefunden, Album 7+8 werden nicht gefunden)\Genre\02 Artist_B\08 Album_8
C:\Tests_1-7\Tests 1-7\Test 2 (es wird nichts gefunden)\Genre\01 Artist_A\01 Album_1
C:\Tests_1-7\Tests 1-7\Test 2 (es wird nichts gefunden)\Genre\01 Artist_A\02 Album_2
C:\Tests_1-7\Tests 1-7\Test 2 (es wird nichts gefunden)\Genre\02 Artist_B\07 Album_7
C:\Tests_1-7\Tests 1-7\Test 2 (es wird nichts gefunden)\Genre\02 Artist_B\08 Album_8
C:\Tests_1-7\Tests 1-7\Test 3 (es wird Album 2 gefunden, Album 1+7+8 werden nicht gefunden)\Genre\01 Artist_A\00 Album_2
C:\Tests_1-7\Tests 1-7\Test 3 (es wird Album 2 gefunden, Album 1+7+8 werden nicht gefunden)\Genre\01 Artist_A\01 Album_1
C:\Tests_1-7\Tests 1-7\Test 3 (es wird Album 2 gefunden, Album 1+7+8 werden nicht gefunden)\Genre\02 Artist_B\07 Album_7
C:\Tests_1-7\Tests 1-7\Test 3 (es wird Album 2 gefunden, Album 1+7+8 werden nicht gefunden)\Genre\02 Artist_B\08 Album_8
C:\Tests_1-7\Tests 1-7\Test 4 (es wird Album 2 gefunden, Album 1+7+8 werden nicht gefunden)\Genre\00 Artist_B\07 Album_7
C:\Tests_1-7\Tests 1-7\Test 4 (es wird Album 2 gefunden, Album 1+7+8 werden nicht gefunden)\Genre\00 Artist_B\08 Album_8
C:\Tests_1-7\Tests 1-7\Test 4 (es wird Album 2 gefunden, Album 1+7+8 werden nicht gefunden)\Genre\01 Artist_A\00 Album_2
C:\Tests_1-7\Tests 1-7\Test 4 (es wird Album 2 gefunden, Album 1+7+8 werden nicht gefunden)\Genre\01 Artist_A\01 Album_1
C:\Tests_1-7\Tests 1-7\Test 5 (es werden Album 2+8 gefunden, Album 1+7 werden nicht gefunden)\Genre\00 Artist_B\00 Album_8
C:\Tests_1-7\Tests 1-7\Test 5 (es werden Album 2+8 gefunden, Album 1+7 werden nicht gefunden)\Genre\00 Artist_B\07 Album_7
C:\Tests_1-7\Tests 1-7\Test 5 (es werden Album 2+8 gefunden, Album 1+7 werden nicht gefunden)\Genre\01 Artist_A\00 Album_2
C:\Tests_1-7\Tests 1-7\Test 5 (es werden Album 2+8 gefunden, Album 1+7 werden nicht gefunden)\Genre\01 Artist_A\01 Album_1
C:\Tests_1-7\Tests 1-7\Test 6 (es werden Album 2+7+8 gefunden, Album 1 wird nicht gefunden)\Genre\00 Artist_B\00 Album_7
C:\Tests_1-7\Tests 1-7\Test 6 (es werden Album 2+7+8 gefunden, Album 1 wird nicht gefunden)\Genre\00 Artist_B\00 Album_8
C:\Tests_1-7\Tests 1-7\Test 6 (es werden Album 2+7+8 gefunden, Album 1 wird nicht gefunden)\Genre\01 Artist_A\00 Album_2
C:\Tests_1-7\Tests 1-7\Test 6 (es werden Album 2+7+8 gefunden, Album 1 wird nicht gefunden)\Genre\01 Artist_A\01 Album_1
C:\Tests_1-7\Tests 1-7\Test 7\Genre 1\Artist 1\Album 1
C:\Tests_1-7\Tests 1-7\Test 7\Genre 1\Artist 2\Album 2
C:\Tests_1-7\Tests 1-7\Test 7\Genre 1\Artist 3\Album 5
C:\Tests_1-7\Tests 1-7\Test 7\Genre 1\Artist 3\Album 6
C:\Tests_1-7\Tests 1-7\Test 7\Genre 1\Artist 3\Album 7
C:\Tests_1-7\Tests 1-7\Test 7\Genre 1\Artist 3\Album 8\CD 1
C:\Tests_1-7\Tests 1-7\Test 7\Genre 1\Artist 3\Album 8\CD 2
C:\Tests_1-7\Tests 1-7\Test 7\Genre 1\Artist 3
notice that i've deleted the file "Erklarung.txt" from the root of Test 1-7 because as mentioned: the script only checks if the folder IS EMPTY, if it's not empty and doesn't have folder.jpg (or other filename that you search) in it, then it puts the whole folder with it's subfolders in the playlist. so if i leave the file "Erklarung.txt", then the script would put the folder "Test 1-7" and all subfolders in the playlist.

check the last line in the above codeboxed output result file:
C:\Tests_1-7\Tests 1-7\Test 7\Genre 1\Artist 3
there is a file "Track 10.mp3" and there is no folder.jpg in it, so it will put the "Artist 3" folder and all subfolder in the playlist

i hope you understand me, and i'll try to change this in the next legendary script (but i'm no sure, as it's always better to keep your folders tight)

and by the way, whichever script is in use, it creates new playlist and doesn't overwrite the current playlist