filename as comment of the file (batch)

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
mattwill
Posts: 4
Joined: 24 Dec 2013 00:41

filename as comment of the file (batch)

Post 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

highend
Posts: 14953
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: filename as comment of the file (batch)

Post 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; }
One of my scripts helped you out? Please donate via Paypal

mattwill
Posts: 4
Joined: 24 Dec 2013 00:41

Re: filename as comment of the file (batch)

Post by mattwill »

Thank you for your help! It works! A beer is on your way :)

highend
Posts: 14953
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: filename as comment of the file (batch)

Post 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:
One of my scripts helped you out? Please donate via Paypal

mattwill
Posts: 4
Joined: 24 Dec 2013 00:41

Re: filename as comment of the file (batch)

Post 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!

highend
Posts: 14953
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: filename as comment of the file (batch)

Post 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)
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 66350
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: filename as comment of the file (batch)

Post 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?

mattwill
Posts: 4
Joined: 24 Dec 2013 00:41

Re: filename as comment of the file (batch)

Post by mattwill »

Thank you for your hint.
Renaming it in XY, the comment is kept.

Post Reply