Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How to combine forfiles and for loop script to run the file  (Read 18223 times)

0 Members and 1 Guest are viewing this topic.

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: How to combine forfiles and for loop script to run the file
« Reply #15 on: October 31, 2014, 06:24:59 AM »
I want the hdf files to remain in the input directory and then the bat file will just detect only if there are new files(based on the date) in the input directory to be project/processed.

If you can't move the files then the script has to keep track of the filenames and compare them all on every loop.

Without knowing the reason why the files need to remain in the folder, and how the folder will grow and never change,
then writing a script is impractical because the details of the project are unknown and we'll have to re-write the script again
when you return to say it fails for a reason that you failed to mention.

_unknown_

    Topic Starter


    Beginner

    • Experience: Beginner
    • OS: Windows 7
    Re: How to combine forfiles and for loop script to run the file
    « Reply #16 on: November 02, 2014, 07:05:13 PM »
    I also asked this from another forum and the second script is what the author answered. I just don't know how to integrate it with the first script.

    _unknown_

      Topic Starter


      Beginner

      • Experience: Beginner
      • OS: Windows 7
      Re: How to combine forfiles and for loop script to run the file
      « Reply #17 on: November 02, 2014, 07:46:11 PM »
      I've decided to just let the processed files moved but can I move it anywhere from the local directory instead (not in the directory where the projected files will be saved)? Because after running the script, the projected files and the processed was kept in the same directory. Another thing, when the projection has finished it will wait for 30 seconds to check if there are newer files in the in_path right? So, I've tried to add files to project in the in_path while the .bat is running and waited if it will detect the new files I've added. But nothing happens. It just count 30 secs again and again.


      foxidrive



        Specialist
      • Thanked: 268
      • Experience: Experienced
      • OS: Windows 8
      Re: How to combine forfiles and for loop script to run the file
      « Reply #18 on: November 02, 2014, 08:42:02 PM »
      I've decided to just let the processed files moved but can I move it anywhere from the local directory instead (not in the directory where the projected files will be saved)? Because after running the script, the projected files and the processed was kept in the same directory.

      Yes, you can change the processed files folder.

      The projected files and processed files should not have been in the same directory.  They should be in two totally different directories.

      Quote
      Another thing, when the projection has finished it will wait for 30 seconds to check if there are newer files in the in_path right? So, I've tried to add files to project in the in_path while the .bat is running and waited if it will detect the new files I've added. But nothing happens. It just count 30 secs again and again.

      It only processes the one filespec that you described, so if there wasn't any screen output then I'd suspect that different filespecs were added.



      _unknown_

        Topic Starter


        Beginner

        • Experience: Beginner
        • OS: Windows 7
        Re: How to combine forfiles and for loop script to run the file
        « Reply #19 on: November 02, 2014, 09:15:00 PM »
        Yes, you can change the processed files folder.

        The projected files and processed files should not have been in the same directory.  They should be in two totally different directories.

        Sorry for this dumb question but I just want to ask if what is the purpose of the temp_path in the script? Because I already have an input_path, and output_path and the processed_files_path.

        Squashman



          Specialist
        • Thanked: 134
        • Experience: Experienced
        • OS: Other
        Re: How to combine forfiles and for loop script to run the file
        « Reply #20 on: November 02, 2014, 09:39:57 PM »
        Sorry for this dumb question but I just want to ask if what is the purpose of the temp_path in the script? Because I already have an input_path, and output_path and the processed_files_path.
        I misunderstood what you need to do.

        This should process the new "*.L2_LAC.*.hdf" files
        by moving them to a staging temp folder so that new files are not confused with the current set
        Then it runs your FORFILES command on the files in the temp folder
        and moves the processed files to a another folder called processed files
        The output files go into your out_path location.

        foxidrive



          Specialist
        • Thanked: 268
        • Experience: Experienced
        • OS: Windows 8
        Re: How to combine forfiles and for loop script to run the file
        « Reply #21 on: November 02, 2014, 09:41:50 PM »
        Squashman pointed it out already - it's a place where processing happens and only appears when the batch file is running. 

        It's a staging folder, a temporary work directory.

        _unknown_

          Topic Starter


          Beginner

          • Experience: Beginner
          • OS: Windows 7
          Re: How to combine forfiles and for loop script to run the file
          « Reply #22 on: November 03, 2014, 12:30:23 AM »
          Still no luck. I've run the bat file again but it doesn't project the newest files added.

          While the .bat is running it created the output directory and the processed files directory. The processed files directory now contained the hdf files, the output directory now contained the projected files. The input directory is now empty because the content was moved to the processed files. The .bat is still running and started to count 30 secs from time to time. I tried to add a new hdf files to the input directory(copied from another directory and pasted it in the input directory), waited if it will project the files I've added but still nothing happens. What is causing this problem? The input files were all the same.

          This are the sample input files I need to project.

          A2000121004500.L2_LAC.A.hdf
          A2000121005000.L2_LAC.A.hdf
          A2000121005500.L2_LAC.A.hdf
          A2000121005550.L2_LAC.A.hdf

          A2000122002500.L2_LAC.A.hdf
          A2000122003000.L2_LAC.A.hdf
          A2000122004500.L2_LAC.A.hdf
          A2000122005500.L2_LAC.A.hdf

          foxidrive



            Specialist
          • Thanked: 268
          • Experience: Experienced
          • OS: Windows 8
          Re: How to combine forfiles and for loop script to run the file
          « Reply #23 on: November 03, 2014, 03:09:14 AM »
          What do you see on the screen?  It works here.

          _unknown_

            Topic Starter


            Beginner

            • Experience: Beginner
            • OS: Windows 7
            Re: How to combine forfiles and for loop script to run the file
            « Reply #24 on: November 03, 2014, 07:50:13 PM »
            I've attached an image of what the screen prints. After running .bat and adding new files to the in_path.

            [attachment deleted by admin to conserve space]

            _unknown_

              Topic Starter


              Beginner

              • Experience: Beginner
              • OS: Windows 7
              Re: How to combine forfiles and for loop script to run the file
              « Reply #25 on: November 03, 2014, 09:00:36 PM »
              There is a "system cannot find the path specified above". Here is how I set my path.

              @echo off
              set in_path=E:\input\
              set out_path=E:\output

              set temp_path=%out_path%\temp\
              set processed_files_path=E:\processed files\
              md "%processed_files_path%" 2>nul
              cd /d "%in_path%"

              Squashman



                Specialist
              • Thanked: 134
              • Experience: Experienced
              • OS: Other
              Re: How to combine forfiles and for loop script to run the file
              « Reply #26 on: November 04, 2014, 06:25:58 AM »
              I've attached an image of what the screen prints.
              You know you can copy and paste text from the CMD window.

              patio

              • Moderator


              • Genius
              • Maud' Dib
              • Thanked: 1769
                • Yes
              • Experience: Beginner
              • OS: Windows 7
              Re: How to combine forfiles and for loop script to run the file
              « Reply #27 on: November 04, 2014, 06:56:41 AM »
              Yeah...but it's a Cool pic though...
              " Anyone who goes to a psychiatrist should have his head examined. "

              _unknown_

                Topic Starter


                Beginner

                • Experience: Beginner
                • OS: Windows 7
                Re: How to combine forfiles and for loop script to run the file
                « Reply #28 on: November 04, 2014, 10:04:58 PM »
                What do you see on the screen?  It works here.

                Did you just set the path and you didn't modify anything when you run the bat file? Because it works in you but in me nothing happens. Please help!
                Maybe the paths is causing the error.

                Squashman



                  Specialist
                • Thanked: 134
                • Experience: Experienced
                • OS: Other
                Re: How to combine forfiles and for loop script to run the file
                « Reply #29 on: November 05, 2014, 06:40:24 AM »
                Lets see the entire batch file that you are using.  Please keep it as is.  Do not obfuscate anything.