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

Author Topic: move each file to a separate folder  (Read 7993 times)

0 Members and 1 Guest are viewing this topic.

mioo_sara

    Topic Starter


    Intermediate

    Re: move each file to a separate folder
    « Reply #15 on: May 30, 2009, 10:36:40 PM »
    my friends billrich and BC_Programmer
    Quote
    It is and was a nonsense and dangerous exercise to move .exe files to a unique folder.
    well .  i  am  using adobe flash all  the times.. unfortunately this program  has a very  weak connection  to  the outside world !! so  if you  want to  work with  some external  files for example(rar- zip -  com -  exe  and...) you  should use fscommand  to  solve it and its really  hard to  find  some useful script for that so  i found another way  batch  scripts !! this way  you  can  reach  to  your goal  faster
    i  am now trying to  make a (file sorter) with  flash   in  this way  users can  upload their files (swf and exe) to my weblog and program  will  sort them  by  their contents (update and uninstall.exe) are just example in  my  question  i  am  finding some kind of pattern
    so  its not a harmful  or as you  said dangerous exercise !!
    it wont even harm  a fly !! thank  you  for being worried  about me :)

    mioo_sara

      Topic Starter


      Intermediate

      Re: move each file to a separate folder
      « Reply #16 on: May 30, 2009, 10:37:21 PM »
      my dear devcom hi :)
      i  should first thank  you  for your great  program  it is really  solving one of  my  biggest problems it can  help  me to  sort my  files easily
      it's wonderful

      ============================
      ok  i tested the program  and found some bugs that you  can  see in  the following:
      test 1
      1-first i  copied some (exe com  txt )  files in  a folder (60 file) and now copied your batch  program
      with first execute it just  find files and made empty folders so  i removed echo from  line (16) and test it again it can  now move them very  nice(thank you)  but it ignored those files that contained updat and uninstall in  their names so i removed : from  lines 8 and 9 and test it again  it moved the rest easily (thanks) but it ignored the last file sorted by  name (renamed alphabetically ) its name was (zz.txt)
      test 2
      so i delet folder and copied another 60 files again  . this time in  your batch scripts first i removed  echo from  line (16) and both : from  lines 8 and 9 this time program find files and made empty  folders but did not moved any  file !! and reached to  "pause" command so  i  execute it again  and it now moved files but left again  last file !!
      now here is my  questions=
      1-  why  progam  can't move files at  the first step?  and i  should start it again  to  move them?
      2- if that last file that is always remain  is hard to  be solved its not a big deal  i  can  live with  that
      3-  when i  removed both  this charactes:: from  lines 15 and 16 it did not workd so  i  remain one : at  the position  so  its working now
      i  thinks if program  finish  its jop at the first step  there wont be other problem
      thanks my  dear lovely devcom

      devcom



        Apprentice

        Thanked: 37
        Re: move each file to a separate folder
        « Reply #17 on: May 31, 2009, 03:45:29 AM »
        Code: [Select]
        @echo off
        setlocal enabledelayedexpansion

        dir /b >log.txt

        for /f "tokens=*" %%A in ('dir /b *.exe *.txt *.com') do (
        md "!fileName!" 2>nul

        set fileName=%%~nA
        ::set fileName=!fileName:update=!
        ::set fileName=!fileName:uninstall=!
        set fileExt=%%~xA

        if "!fileExt!" equ ".txt" (set moveName=readme) ELSE (set moveName=setup)

        call :FIND "%%A"

        echo move "%%A" "!fileName!\!moveName!!fileExt! >>log.txt

        )
        pause
        exit

        :FIND
        set find=%~1
        echo.%find% |findstr /I "uninstall" >nul && set moveName=Uninstall
        echo.%find% |findstr /I "update" >nul && set moveName=Update
        exit /b

        could you run this code and post here content of log.txt ? because on my comp it works like it should, and i want to identify the problem ;)
        Download: Choice.exe

        mioo_sara

          Topic Starter


          Intermediate

          Re: move each file to a separate folder
          « Reply #18 on: May 31, 2009, 04:59:46 AM »
          ok  i will my friend

          mioo_sara

            Topic Starter


            Intermediate

            Re: move each file to a separate folder
            « Reply #19 on: May 31, 2009, 05:38:27 AM »
            my dear devcom hi ;)
            well  i replaced .com  to rar so  you  can  see it in  report
            but with  executing bat file it just made empty  folders(i did not removed echo this time)
            in reported log file i can  see just names of files !! but in  CMD window its different so  i put a picture of that window too



            here is log file

            Quote
            flah to java.com
            flash  games 1.rar
            Flash Handout v1.0 Evaluation.exe
            FlashPPT 2008.rar
            KeepV Flash Converter.exe
            learn  flash 1.txt
            learn  flash 2.txt
            learn  flash 3.txt
            log.txt
            MacroMedia Flash Paper v2.01.2283.exe
            mybat.bat
            uninstall.exe
            weeekly update.exe
            Wondershare PPT to Flash Studio(Build 2.9.0.2) Trial Version.exe

            devcom



              Apprentice

              Thanked: 37
              Re: move each file to a separate folder
              « Reply #20 on: May 31, 2009, 06:01:33 AM »
              omfg...

              i think i had accidentally erased " from:
              Code: [Select]
              move "%%A" "!fileName!\!moveName!!fileExt!"
              so change this:
              Code: [Select]
              move "%%A" "!fileName!\!moveName!!fileExt!to:
              Code: [Select]
              move "%%A" "!fileName!\!moveName!!fileExt!"
              and try then
              Download: Choice.exe

              mioo_sara

                Topic Starter


                Intermediate

                Re: move each file to a separate folder
                « Reply #21 on: May 31, 2009, 07:35:27 AM »
                my dear devcom hi thanks its better now
                this time something changed as i mentioned in  2  last post it worked but not in the first place so i  should start batch  program  twice  in the first step  it make folders and after executing batch  program  again  it  move files to  folders but it still  remains 1 file !
                new test
                this time i just created 3 files to see what's wrong(if it's possible create 3 files as you  can  see in  below picture)



                1-by  the way  in  my  batch  code i  have this 4 lines if i  want to  sort update and uninstall

                Quote
                set fileName=%%~nA
                :set fileName=!fileName:update=!
                :set fileName=!fileName:uninstall=!
                set fileExt=%%~xA
                i  can't remove all : character or it will  ignore uninstall  and update if they  are exist
                2-  i   changed  .com  to  .rar in  batch  program
                you  can  see error message in  the first step (but it create empty  folders and renamed them very nice)

                3-  i am  using windows xp sp2

                devcom



                  Apprentice

                  Thanked: 37
                  Re: move each file to a separate folder
                  « Reply #22 on: May 31, 2009, 08:14:10 AM »
                  ok now im confused...

                  Code: [Select]
                  @echo off
                  setlocal enabledelayedexpansion

                  for /f "tokens=*" %%A in ('dir /b *.exe *.txt *.com') do (

                  set fileName=%%~nA
                  REM set fileName=!fileName:update=!
                  REM set fileName=!fileName:uninstall=!
                  set fileExt=%%~xA

                  md "!fileName!" 2>nul

                  if "!fileExt!" equ ".txt" (set moveName=readme) ELSE (set moveName=setup)

                  call :FIND "%%A"

                  echo move "%%A" "!fileName!\!moveName!!fileExt! >>log.txt

                  )
                  pause
                  exit

                  :FIND
                  set find=%~1
                  echo.%find% |findstr /I "uninstall" >nul && set moveName=Uninstall
                  echo.%find% |findstr /I "update" >nul && set moveName=Update
                  exit /b

                  run this code and do not change anything.. if it will not work remove '@echo off' at first line and then start this batch from CMD and post here the output
                  Download: Choice.exe

                  mioo_sara

                    Topic Starter


                    Intermediate

                    Re: move each file to a separate folder
                    « Reply #23 on: May 31, 2009, 09:29:10 AM »
                    wow thanks god and thank you  my  dear lovely devcom
                    its working like a machine gun !!! how did you  do  that?
                    i could not belive my  eyes thank you  1000 time
                    to  me you  are a WIZARD

                    something else=i  changed  this in  your last post
                    Quote
                    move "%%A" "!fileName!\!moveName!!fileExt!
                    to
                    move "%%A" "!fileName!\!moveName!!fileExt!"

                    if it was with  me i  could not solve the problem  untill  next christmas
                    i wish  you  be healthy  and happy  in  your entire life
                    by the way  i  am  not going to bother you  but if you  have time  and if it is possible help me with  my  another question

                    Quote
                    http://www.computerhope.com/forum/index.php/topic,84290.0.html
                    i am  really  stuck
                    and if you  don't have time  i already  thank  you  again