Sort music files and go to the target folder

I fixed the buttons using *.wma instead of *.mp3 (something I changed when testing it and forgot to change back).

If you want to move the whole current directory, add this to the end of the VBScript, just before the End Function line:

	strNewName = ""

That will make it so the Rename line doesn't actually rename or move the files at all, but still sets the RENAME_TARGET env-var.

Now you should be able to use %RENAME_TARGET% as the destination in a Copy MOVE command, similar to how your original button worked.

This works for me now:

Copy MOVE * TO "%RENAME_TARGET%"
Go PATH ".." DUALPATH "%RENAME_TARGET%"
rmdir {$OriginalSource}

But surely it's a dangerous Button this way. No Problem to use it by mistake on Folders containing no MP3-files because you'll get an error message. Otherwise it will move erything to my Music directory...

I tried the above before reading your last post. This way it worked, but does a second Move-action. With your additionally strNewName = "" it's perfekt now. Thanks again and again!

If you click that button in a folder without any music files then it'll move the current folder's contents to whatever the previous music destination was, if you had used the button since starting Opus. Else it would use an empty destination, which I don't think will do anything (not sure, actually).

You could make it a bit safer by adding this right after the Set EnvVars = Shell.Environment("PROCESS") line:

EnvVars("RENAME_TARGET") = "zzzzz:\"

That sets the default destination to zzzzz:\ which is an impossible path and will result in an error message instead of anything happening. The destination will be left that way if the rename script doesn't get to run for any files.

@leo:
I was too quick to say it's perfekt with strNewName = "":

It should rename the files and create the folder-structure based on tags. Just the "Move to %RENAME_TARGET%" Part should be skipped.

Just for Fun I added a Line calling my favourite music player to play all files in "%RENAME_TARGET%" right behind the rmdir {$OriginalSource} command.
Worked on the first try.
Here's the simple Code (using Aimp2):

"C:\Program Files\AIMP2\AIMP2.exe" %* "%RENAME_TARGET%"

Ah, true. Well, you can always do both, so the Rename command takes care of the MP3 files and then a Copy MOVE command moves any additional files which are still leftover.

BTW, I edited your post above to put quotes around the AIMP2.exe path. Makes it work if something creates a folder called "C:\Program" (which happens every so often).

WOW NICE WORK ... I know you said no questions but what happens if there are no tags ? I did not see it .. I will try it with a file that has no tags.. I asked it here so its under the same place just in case someone wants to know... update I just tried on a file with no tags . all i got was a file named 13.mp3 ... so a bit scary can it be updated to take no actions on files with no tags

The whole thing could be done in a better way now, with the improved scripting functionality added to Opus over the last 7 years.

Not something I have time to do right now but I can offer some pointers if anyone else wants to.

well i only came across it because looking for info on rename presets for music

i will post in questions did not know it was 7 years old

would love for this to be updated

can we have a nice new version of this please ? or is this something better already i have not asked about for sometime even if it could be updated not to move files / folders with blank tags thanks again

Original script seems to have gotten broken at one point as it no longer works properly in 12
This is a great script. Sad it's no longer supported

Leo, If you still haven't found the time I'd be willing to look at some pointers.

If I didn't thank you 7+ years ago, I'll thank you now. That script was indispensable!

Thanks

What goes wrong?

It doesn't seem to be picking up the track info on the files. I have checked and the files are tagged with ID3v2.3 tag format. I tried retagging so they also have ID#v1 as well
It doesn't seem to create the folder based on the artist and album name.
It creates a single file with no name on the first file and then the second file generates a renaming error: "Cannot create a file when that file already exists"

Also, I notepad text is generated and opened when the process completes: dop201912132119220083.bat

echo off
chcp 1252 > nul
D:
cd "\Downloads"
rmdir D:\Downloads\Gong_-_The_Universe_Also_Collapses_(2019)

Thanks

Just in case, here's the script I've used for years but I did just grab the one from the forums here, created a new button and get the same results

@noexpandenv
@runmode hide
@set OriginalSource={sourcepath$|noterm}
Rename FILEINFO FROM "*.mp3" TO "{alias|mymusic}\{mp3artist}\{mp3album}\{mp3track|#2} - {mp3title}.{ext}"
Go PATH ".." DUALPATH "%RENAME_TARGET%"
rmdir {$OriginalSource}
@script vbscript
Option Explicit
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
Dim Shell
Set Shell = CreateObject("WScript.Shell")
Dim EnvVars
Set EnvVars = Shell.Environment("PROCESS")
Function Rename_GetNewName(strFileName, strFilePath, fIsFolder, strOldName, ByRef strNewName)
   ' Fix any double \ chars resulting from empty tags (e.g. no genre).
   ' If we don't do this, things can get confused about the destination path.
   strNewName = Replace(strNewName, "\\", "\")
   ' Set the %RENAME_TARGET% environment variable to the folder we're moving the file to.
   ' This can be used in the main command above to go to the folder.
   ' Note that we use "@noexpandenv" at the top of the command; if we didn't then %RENAME_TARGET%
   ' would be expanded *before* this script had run, which obviously would not work.
   EnvVars("RENAME_TARGET") = fs.GetParentFolderName(strNewName)
End Function

If you add the music track, artist, etc. columns to the file display, what does it show for that mp3 file?

Nothing shows up in those columns. Is it an issue with the tags? I know the files are tagged.

Most likely. Can you send me a sample file via private message? (Zip it first as the forum won't allow .mp3 attachments.)

Sent

Opus shows the music tags for that file OK here.

Have you disabled the AudioTags plugin (Preferences / Viewer / Plugins) or anything like that?