• WSvik1

    WSvik1

    @wsvik1

    Viewing 5 replies - 1 through 5 (of 5 total)
    Author
    Replies
    • Thank you Sir. Will try it out.

    • in reply to: Batch Script to move all but newest 3 files #1560901

      Thanks a million !

    • in reply to: Batch Script to move all but newest 3 files #1559707

      I have another query. How to move files from one location, to two locations?

      I have written a batch, but it moves to only the first location (target1), and not the second.

      @echo off
      move /-y “c:source*.wav” “c:target1”
      move /-y “c:source*.wav” “c:target2”

      Please help. Appreciate your reply.

      Regards,

      Vik

    • in reply to: Batch Script to move all but newest 3 files #1559699

      Thanks so much. Worked perfectly !

      Regards

      Vik

    • in reply to: Batch Script to move all but newest 3 files #1559635

      Hi All,

      Greetings !

      The discussion above was quite helpful. I feel ashamed that I am copying the work you good people are doing. But anyways, it is helping me. I can only say Thank You !

      I was just wondering, if we need to move files with a particular extension ( here a notepad – .txt ), what changes should I make to your code ? [Where do I place the .txt]

      @echo off
      setlocal
      :: change the next two statements to match what you want
      set srcdir=c:source
      set tgtdir=c:target
      if not exist %tgtdir%*.* md %tgtdir%
      set ctr=0
      for /f “tokens=*” %%a in (‘dir “%srcdir%” /o-d /b’) do call :maybemove “%%a”
      set /a ctr-=3
      echo %~n0: %ctr% files were moved from %srcdir% to %tgtdir%
      endlocal
      goto :eof
      ::——————–

      :maybemove
      :: increment counter and bypass the three newest files
      set /a ctr+=1
      if %ctr% leq 3 goto :eof
      :: remove the double-quotes from the front and back of the filename
      set fn=%~1
      :: perform the move
      move /y “%srcdir%%fn%” “%tgtdir%”
      goto :eof

      Regards,

    Viewing 5 replies - 1 through 5 (of 5 total)