chdkptp rm (was Re: CHDKPTP - PC Remote Control Performance Analysis) - General Help and Assistance on using CHDK stable releases - CHDK Forum

chdkptp rm (was Re: CHDKPTP - PC Remote Control Performance Analysis)

  • 2 Replies
  • 4520 Views
Advertisements
OK, but this is too much to type every time, we want it a lua file, and we don't want the CANONMSC directory (my camera didn't have one). We also want and option to remove the files, some indication if there is an error. Since we are playing with delete, we probably want a pretend option to test it too.

extras/dcimdl.lua
Code: [Select]
function dcimdl(destdir,del,pretend)
   if pretend then
      pretend = '-pretend '
   else
      pretend = ''
   end
   local dcim,err=con:listdir('A/DCIM')
   if not dcim then
      printf('error listing directory %s\n',tostring(err))
      return
   end
   for i,dname in ipairs(dcim) do
      if dname ~= 'CANONMSC' then
         cli:print_status(cli:execute('mdl '..pretend..' -fmatch=%.[JDC][PNR][G2]$ DCIM/'..dname..' '..destdir))
         if del then
            cli:print_status(cli:execute('rm '..pretend..' -nodirs -fmatch=%.[JDC][PNR][G2]$ DCIM/'..dname))
         end
      end
   end
end

I'm a bit bogged down in the rm syntax to permanently delete any CCHDK*.CFG from A/CHDK.

A hand with that would be appreciated.
« Last Edit: 19 / October / 2017, 18:12:25 by reyalp »

*

Offline reyalp

  • ******
  • 14119
Re: chdkptp rm (was Re: CHDKPTP - PC Remote Control Performance Analysis)
« Reply #1 on: 19 / October / 2017, 18:19:03 »
I'm a bit bogged down in the rm syntax to permanently delete any CCHDK*.CFG from A/CHDK.

A hand with that would be appreciated.
Code: [Select]
___> help rm
delete (rm)  [options] <target, target,...>: - delete file/directories from the camera
 <target...> files/directories to remote
 options:
   -fmatch=<pattern> upload only file with names matching <pattern>
   -dmatch=<pattern> only delete directories with names matching <pattern>
   -rmatch=<pattern> only recurse into directories with names matching <pattern>
   -nodirs           don't delete directories recursed into, only files
   -maxdepth=n       only recurse into N levels of directory
   -pretend          print actions instead of doing them
   -ignore_errors    don't abort if delete fails, continue to next item
   -skip_topdirs     don't delete directories given in command line, only contents
 note <pattern> is a lua pattern, not a filesystem glob like *.JPG
(oops, "upload" on fmatch is a typo, of course it should be delete  :-[)

-pretend is your friend
Code: [Select]
con> rm -pretend -nodirs -fmatch=%.CFG$ CHDK
A/CHDK/DATA/DEFAULT.CFG: OK
A/CHDK/DATA/FIXEDINT.CFG: OK
A/CHDK/DATA/MDFB2013.CFG: OK
A/CHDK/DATA/MFVALS.CFG: OK
A/CHDK/DATA/ISOINC.CFG: OK
A/CHDK/CCHDK4.CFG: OK
A/CHDK/OSD__4.CFG: OK
Don't want to recurse... limit with maxdepth
Code: [Select]
con 2> rm -pretend -nodirs -maxdepth=1 -fmatch=%.CFG$ CHDK
A/CHDK/CCHDK4.CFG: OK
A/CHDK/OSD__4.CFG: OK
Don't forget what the H stands for.

Re: chdkptp rm (was Re: CHDKPTP - PC Remote Control Performance Analysis)
« Reply #2 on: 20 / October / 2017, 02:27:09 »
Useful - thanks.

(I had noticed the typo in the usage file but forgot to mention - apologies. Maybe you can correct that soon).

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal