-
So I'm trying to create a menu item which will let me copy each folder using Windows built in Robocopy application. I can already use the following script to copy a single folder. But I don't know how to achieve this when I select multiple folders. Working script for a single file: ( " is used to escape quotes in terminal ) $directory_prompt="Please enter the directory path."
item(title='Copy' cmd='pwsh.exe' args='-noexit -command $path = Read-Host @directory_prompt; roboCopy \"@sel.path\" \"$path\\@sel.name\" /E /R:30 /MT:16 /ETA') So the terminal application receives this: -noexit -command $path = Read-Host "Please enter the directory path."; roboCopy "D:\foldername" "$path\foldername" /E /R:30 /MT:16 /ETA If I were to explain this in Javascript, I want something like this: const commandToExecute = "$path = Read-Host @directory_prompt;"
selectedFolders.map(folder => {
// Iterate over each and append them to the commandToExecute variable
commandToExecute + ` roboCopy \"${folder.path}\" \"$path\\${folder.name}\";`
})
executeInTerminal(commandToExecute) Is it possible to achieve something like this in the current version 1.9.18? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I don't use Robocopy, someone asked me to help build snippet for him (the logic is not mine) menu(title='robocopy' mode='multiple' type='file|dir|back.dir') {
$rc_memory=null
item(title='Copy Files Only' mode='multiple' type='file' image=icon.copy
cmd=for(i=0, i<sel.count) {
if(i==0, rc_memory=null)
rc_memory = rc_memory + 'robocopy ' + quote(if(sel[i].type==1, path.parent(sel[i]), sel[i])) + ' ' + quote('####') + if(sel[i].type==1, ' ' + quote(path.file.name(sel[i])) ) + if(i<sel.count-1, ' & ') })
item(title='Copy' mode='multiple' type='file|dir' image=icon.copy
cmd=for(i=0, i<sel.count) {
if(i==0, rc_memory=null)
// if(i==0, if(keys.shift() and len(rc_memory)>0, { rc_memory = rc_memory + ' & ' } , { rc_memory=null } ))
rc_memory = rc_memory
+ if(sel[i].type==1, 'robocopy ' + quote(path.parent(sel[i])) + ' ' + quote('####') + ' ' + quote(path.name(sel[i])))
+ if(sel[i].type==3, 'robocopy ' + quote(sel[i]) + ' ' + quote('####\' + path.name(sel[i])) + ' /E')
+ if(i<sel.count-1, ' & ') })
menu(mode='single' where=len(rc_memory)>0 type='dir|back.dir' expanded='true') {
item(title='Check Memory' image=\ue249
cmd=msg(str.replace(rc_memory, '####', sel)))
item(title='Clear Memory' image=\ue249
cmd={ rc_memory=null })
item(title='Paste' image=icon.paste
cmd-line='/k ' + str.replace(rc_memory, '####', sel) + ' & pause & exit')
item(title='Paste (hidden)' image=icon.paste commands {
cmd-line='/c ' + str.replace(rc_memory, '####', sel) window='hidden',
cmd=msg('Done!') })
}
} you will need
|
Beta Was this translation helpful? Give feedback.
I don't use Robocopy, someone asked me to help build snippet for him (the logic is not mine)