Page 1 of 1

filename as comment of the file (batch)

Posted: 24 Dec 2013 00:49
by mattwill
Hello,
is it possible to save the filename in the comment(field).
Hello123.avi -> Then Comment: Hello123 or Hello123.avi

It could be a XYComment or a Windows Comment.

I have thousand of files, so a batch file would be great.

Thank you for your help.

Mattwill

Re: filename as comment of the file (batch)

Posted: 24 Dec 2013 02:40
by highend
Takes all files from the current folder (non recursive)...

Code: Select all

// Take the base name of a file and put it in the comment field
    foreach($file, listfolder(, "*", 1, "|"), "|") { tag getpathcomponent($file, "base"), $file, 2; }

Re: filename as comment of the file (batch)

Posted: 25 Dec 2013 11:17
by mattwill
Thank you for your help! It works! A beer is on your way :)

Re: filename as comment of the file (batch)

Posted: 25 Dec 2013 12:39
by highend
mattwill wrote:Thank you for your help! It works! A beer is on your way :)
No problem and thanks! :biggrin: :beer: :beer: :beer:

Re: filename as comment of the file (batch)

Posted: 28 Dec 2013 00:52
by mattwill
When i change the filename, the comment is gone!
But i would save the original filename as comment, so i could rename the files.

Is there any chance to do that.
Thank you for your help!

Re: filename as comment of the file (batch)

Posted: 28 Dec 2013 01:56
by highend
I guess you could use a tag instead (sorry, I don't work neither with comments, nor with tags).

Tags will be overriden, be careful.

Change this part

Code: Select all

{ tag getpathcomponent($file, "base"), $file, 2; }
to

Code: Select all

{ tag getpathcomponent($file, "base"), $file, 1, 1; }
Menu - Tools - Configuration... - Startup & Exit - Save settings on exit should be checked (to save tags on exit)

Re: filename as comment of the file (batch)

Posted: 28 Dec 2013 09:17
by admin
mattwill wrote:When i change the filename, the comment is gone!
This should not happen when you change it within XY. Do you?

Re: filename as comment of the file (batch)

Posted: 29 Dec 2013 13:23
by mattwill
Thank you for your hint.
Renaming it in XY, the comment is kept.