Questions about SFK replace: Dirs, patterns

2008-08-12
2013-01-06
  • Michael Jennings

    Questions about SFK Replace:

    1) How do I prevent SFK from processing sub-directories? Using the -tracesel parameter, I discovered that the following:
    -dir .\ -file TestFile.txt
    processes all sub-directories.

    2) When doing a test I get this standard output from a replace:
    [total hits/matching patterns/non-matching patterns]
    [121/19/3]
    There are 3 non-matching patterns. How can I learn which patterns didn't match?

    Thanks for SFK, it solves a lot of problems for me.

    Michael Jennings

     
    • stahlworks

      stahlworks - 2008-08-12

      > How do I prevent SFK from processing sub-directories?

      with the -nosub option. type "sfk help opt" for general options.
      your question tells me the help text isn't clear enough on that.
      maybe i have to list -nosub explicitely on major commands.

      > How can I learn which patterns didn't match?

      with the -verbose option. seems to be missing completely in the help,
      this will be fixed.

       
      • Michael Jennings

        Thanks!!!

        I searched for verbose, but didn't find it.

        Everyone needs to know about these options:
        -nocase -nosub -verbose -tracesel

        I think -nosub should be the default. It scares me to think what could happen if someone doesn't realize that all the sub-directories are being processed. Someone, for example, could process a binary file in the root directory.

        It seems to me that the first three options could be the default; -nocase is already the default; the output of each option could include instructions in how to change the default. It seems to me that, when something other than the default is chosen, there should be a message on standard out.

        The documentation needs to be improved, in my opinion. I'm a professional writer; if you like, I will help you with the documentation. (I've offered several times before to help document an open source project, but project leaders have felt concerned about letting someone else do some writing.)

        Michael Jennings

         
    • stahlworks

      stahlworks - 2008-08-13

      > It seems to me that the first three options could be the default

      the magic of sfk is that, by default, you can process all files of all subdirectories, instantly. this is the default for all commands that can process several files. no "dir /S /B" cryptic stuff, but simply "sfk list" and you get all filenames, period. therefore subdirectory processing will stay default in general. i will think if an exception is appropriate in the case of high risk commands like replace. but even such commands run in simulation, by default, so the user will see what would be processed.

      -verbose will never be default, it means endless spamming with information that most users do not want to see. what is missing now is only the info that -verbose exists, for the case that a command behaves unexpected.

      > if you like, I will help you with the documentation

      thanks, but so far, i think that the live help within sfk.exe is complete, apart from a few options. the problem is that users don't find everything, or are too lazy to really read every line of the help. the next release will come with a command to dump the whole help (of every command) and also to search it for given words.

      however, i'm open to documentation outside sfk.exe; for example, an html help file that explains everything in a different way. i'll get back to you by mail.

       
    • doppiamunnezza

      doppiamunnezza - 2009-08-02

      Hi to everyone in the forum and thanks to stahlworks for sfk i think it's a great tool.
      Hope not being off topic (excuse my english anyway ..) but talking about dirs and replace here is what i'm trying to do, with no success till now ...,:
      I have a dir with about 500 subdirs (all first level subdirs) the name schema of this subdirs is
      aaaaa.bbbb.cccc.ddddd.eeeee. ... and so on and i want to rename all the subdirs like this
      aaaaa bbbb cccc ddddd eeeee ... in other words i just want to replace dots with spaces.
      I was trying this command line:
      sfk list -justdirs +filter -rep _._" "_ +run "ren $qfile $qtext"
      but the simulated ren command has both the arguments (oldname, newname) equal to the
      new name (the one with spaces instead of dots) .
      I think i'm a bit stuck ..... any suggestion???

      Thanks in advance.

       
      • stahlworks

        stahlworks - 2009-08-03

        qtext is basically the same as qfile, only with less checks (it doesn't verify if the file exists). so in your command you only produce the same text twice.

        basically you need to replace text in one part of a line (the target dir name), but not in the other part (the source). my only solution is a script that produces an intermediate batch file as a workaround.

        --------- rendirs.bat begin ------
        @echo off
        sfk script rendirs.bat -from begin %*
        .\zz-tmp1.bat
        GOTO xend

        sfk label begin
           +list -justdirs .
           +filt -sform "ren $qcol1\n}$qcol1"
           +filt -where "}" -rep "_._ _"
           +tofile zz-tmp1.bat
           +then replace -yes -quiet zz-tmp1.bat -spat "/\r\n}/ /"
           +end
        :xend
        -------- rendirs.bat end ----------

         

Log in to post a comment.