ExifTool Forum

ExifTool => Newbies => Topic started by: chrispopp8 on September 07, 2016, 07:32:30 PM

Title: Script won't write to output file
Post by: chrispopp8 on September 07, 2016, 07:32:30 PM
I've created a batch file that will output a .m3u playlist of mp3 files. I want to be able to have my .m3u playlist be in track order.

@echo off 
chcp 1252 
cd %1 
echo %~f1 
exiftool -q -p "$Filename" -fileorder TrackNumber -ext mp3 -ext flac -ext m4a . > "%~nx1.m3u" 


I've placed exiftool in my c:\ dir as well as tried it in c:\windows. I've added these locations to my path in Windows 10.

The file is created but is empty.

I've tried both a manual start using the batch file from the command line as well as using a right-click of a folder using a registry edit.

Any help is appreciated.
Title: Re: Script won't write to output file
Post by: StarGeek on September 07, 2016, 09:35:16 PM
Welcome to the forums, sorry I couldn't be more helpful on reddit.

QuoteI've tried both a manual start using the batch file from the command line

Unfortunately, it won't work from the command line as it is.  From the command line by itself, it will take the current directory as the target.  If you add a directory as an argument on the command line, it should work if it's on the same drive, but it won't if the target directory is on a different drive.

Try dragging the bat file to the desktop and then dropping a directory on it.  That's what worked for me.   Also, what version of Windows are you using?

Reddit thread source (https://www.reddit.com/r/techsupport/comments/51hr4y/m3u_creation_via_right_click/) for anyone else to catch up with.
Title: Re: Script won't write to output file
Post by: StarGeek on September 08, 2016, 02:05:47 AM
I do notice one mistake that I made, but it shouldn't have affected the results.  It should be Track and not TrackNumber.  Not sure where I dug TrackNumber up from.
Title: Re: Script won't write to output file
Post by: chrispopp8 on September 08, 2016, 03:32:58 PM
Running Windows 10.

The music is on the H:\ drive

Also - the registry edit I have made to allow me to right click on the folder is this:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\play]
@="Make playlist(s)"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\play\command]
@="cmd /C C:\\makeplaylist.bat \"%L\""
Title: Re: Script won't write to output file
Post by: StarGeek on September 08, 2016, 03:39:13 PM
Try changing the 3rd line from this:
cd %1
to this
cd /D %1

I should have looked at your bat file a bit closer.  The /D option changes the drive as well as the directory.
Title: Re: Script won't write to output file
Post by: ryerman on September 08, 2016, 05:08:52 PM
Maybe there's a problem with the files.
Try changing the -q option to -k and see what Exiftool reports.
Title: Re: Script won't write to output file
Post by: chrispopp8 on September 10, 2016, 04:31:59 PM
Got this to work by placing exiftool in the root of the drive that my music files are in.

But now I have a new problem: If there's an & in the directory name, the batch file doesn't like it and does not recognize everything after the &
Title: Re: Script won't write to output file
Post by: ryerman on September 10, 2016, 05:18:58 PM
Here is a 1 line BAT file that creates a playlist in whatever folder is provided as its argument.

exiftool -q -p "$Filename" -fileorder TrackNumber -ext mp3 -ext flac -ext m4a %1 > "%~1\playlist.m3u"

I can't say it will work for any folder path, but it works for folders with "&" in the path.