code bug about ffmpeg file date Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
joshatt
Posts: 151
Joined: 07 Dec 2014, 08:41

code bug about ffmpeg file date

01 Feb 2019, 08:51

Code: Select all

SetWorkingDir g:\source

#m::
Loop, %A_WorkingDir%\NEWS*.mp4
{
	FileGetTime,mt,A_LoopFileLongPath
	runwait,ffmpeg -y -i %A_LoopFileLongPath% -ss 8 -vcodec copy -acodec copy "g:\outpt\%A_LoopFileName%.mp4"
	filesettime,mt,g:\outpt\%A_LoopFileName%
}
return
There's a ffmpeg bat that could cut off begining 8 seconds of all mp4 files, but the result files' date are all of today. I want it keep original date, i.e. modification date. So I wrote the above code. After simple test (I put 4 files with filename "News****" in source folder), there're 2 bugs:
1, only two files appear in outpt folder;
2, date is still today, not as expected

Any idea?
gregster
Posts: 9000
Joined: 30 Sep 2013, 06:48

Re: code bug about ffmpeg file date  Topic is solved

01 Feb 2019, 09:18

There could be more problems (with the parameters in runwait), but this cannot work:

Code: Select all

FileGetTime,mt,A_LoopFileLongPath
This looks for a file literally named A_LoopFileLongPath, but instead you want to read the variable's contents (for example by forcing an expression):

Code: Select all

FileGetTime, mt, % A_LoopFileLongPath
2, date is still today, not as expected
The error above leads to mt being blank... FileSetTime then does this:
https://autohotkey.com/docs/commands/FileSetTime.htm wrote:If blank or omitted, it defaults to the current time.
To discover problems like this, I'd recommend using a msgbox now and then as a simple debugging technique (of course, you can go wilder, if you want)

btw, A_LoopFileName contains the file's extension, afaik... so, adding mp4 will probably lead to .mp4.mp4.
joshatt
Posts: 151
Joined: 07 Dec 2014, 08:41

Re: code bug about ffmpeg file date

01 Feb 2019, 18:39

gregster wrote:
01 Feb 2019, 09:18
There could be more problems (with the parameters in runwait), but this cannot work:

Code: Select all

FileGetTime,mt,A_LoopFileLongPath
This looks for a file literally named A_LoopFileLongPath, but instead you want to read the variable's contents (for example by forcing an expression):

Code: Select all

FileGetTime, mt, % A_LoopFileLongPath
2, date is still today, not as expected
The error above leads to mt being blank... FileSetTime then does this:
https://autohotkey.com/docs/commands/FileSetTime.htm wrote:If blank or omitted, it defaults to the current time.
To discover problems like this, I'd recommend using a msgbox now and then as a simple debugging technique (of course, you can go wilder, if you want)

btw, A_LoopFileName contains the file's extension, afaik... so, adding mp4 will probably lead to .mp4.mp4.
Thank you so much, sir. Everything works now!

I replaced

Code: Select all

runwait,ffmpeg......%A_LoopFileLongPath%......"g:\outpt\%A_LoopFileName%.mp4"
with

Code: Select all

runwait,ffmpeg......"%A_LoopFileLongPath%"......"g:\+linshi\%A_LoopFileName%"
It works. Some files fail because of spaces in filename.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lamron750 and 354 guests