Moving a file to a backup folder

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

jigsaw

Moving a file to a backup folder

Post by jigsaw »

Hi,

When a file is selected from a folder through photoshop, it has to be opened in photoshop and simultaneously that file has to move from the source folder to the predefined folder. Is this possible.

EG:
C:\Test\1.jpg

After running the script:
Source Folder
C:\Test\null

Predefined folder:
C:\Process\1.jpg

Also it should be opened in photoshop.
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: Moving a file to a backup folder

Post by Kukurykus »

All is like in an author description. The best is to bind a script to Photoshop action and then call it by a key stroke.

Code: Select all

fls = (fld = Folder((dsk = '~/Desktop') + '/Source/')).getFiles(/\.(jpg|tif|psd|bmp|gif|png)$/i)
if (fls.length) {
win = new Window ("dialog"); win.center(), win.margins = 3; win.spacing = 2
for(i = 0; i < fls.length; i++) {
grp = win.add('group'); grp.alignment = "right";
eval("fle" + i + " = " + "grp.add('statictext', undefined, String(fls[i]).replace(/.*\\//, ''))")
eval("sel" + i + " = " + "grp.add('button', [0, 0, 40, 18], 'Select')")
}
for(j = 0; j < fls.length; j++) {
eval("sel" + j + ".onClick = function() {win.close(), (dlt = File(fld + '/' + nme = fle" + j + ".text)).copy(opn = dsk + '/Process/' + nme)}")
}
win.show(), dlt.remove(), open(File(opn))
}
else (alert('Folder at the end of ' + fld + ' path is empty!'))
Attachments
File Selection.zip
(773 Bytes) Downloaded 344 times