Rather special file copy question...

Discuss and share scripts and script files...
Post Reply
ThomasHelzle
Posts: 39
Joined: 21 Dec 2016 15:08
Contact:

Rather special file copy question...

Post by ThomasHelzle »

Hi,

I never did a XYplorer script before and from the docs I was unsure how to approach this:

I have a folder full of .jpg files and one file called default.jpg.pnt.
What I need to do is, for each .jpg file in the current folder, I need to create a copy of the default.jpg.pnt but with the name of the .jpg files instead of the "default".
So
filename.jpg will duplicate the default.jpg.pnt file as filename.jpg.pnt
otherfile.jpg will duplicate the default.jpg.pnt file as otherfile.jpg.pnt
and so on...

My idea is, that I have some kind of list of all the .jpg files in the folder as an array and then copy the default.jpg.pnt file for each .jpg file replacing the first part of the name with the name from the array.

If anybody has some pointers for me how to do this, I'd be thankful. In the meantime I'll try how far I can get on my own...

Thanks and cheers,

Tom
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." - Rumi
ScreenDream|Thomas Helzle 8) Mastodon

ThomasHelzle
Posts: 39
Joined: 21 Dec 2016 15:08
Contact:

Re: Rather special file copy question...

Post by ThomasHelzle »

Okay so in theory I figured it out:

$folder = inputfolder(, "Select Input Folder");
 $itemlist = listfolder($folder, ".jpg", 1 + 4);
 foreach($image, $itemlist) {
  copyitem "$folder\default.jpg.pnt" "$folder\$image.pnt";
 }


But in practice nothing happens, although I can see with Try Script that all the right things seem to happen internally.
Am I missing something basic here?

Thanks for any pointers!

Tom
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." - Rumi
ScreenDream|Thomas Helzle 8) Mastodon

ThomasHelzle
Posts: 39
Joined: 21 Dec 2016 15:08
Contact:

Re: Rather special file copy question...

Post by ThomasHelzle »

Weird, when I use "new" instead of "copyitem" it works... :?:

So my script now looks like:

$folder = inputfolder(, "Select Input Folder");
$itemlist = listfolder($folder, ".jpg", 1 + 4);
foreach($image, $itemlist) {
new("$folder\$image.pnt", , "$folder\default.jpg.pnt");
}

Not really that intuitive but works for my needs now.

Cheers,

Tom
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." - Rumi
ScreenDream|Thomas Helzle 8) Mastodon

Post Reply