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

Author Topic: File Type Organizer..??  (Read 16924 times)

0 Members and 1 Guest are viewing this topic.

gumbaz

    Topic Starter


    Intermediate

    Re: File Type Organizer..??
    « Reply #15 on: February 01, 2009, 03:26:52 PM »
    Anybody see whats going wrong in my code at all..??

    Dias de verano

    • Guest
    Re: File Type Organizer..??
    « Reply #16 on: February 01, 2009, 03:31:56 PM »
    Anybody see whats going wrong in my code at all..??

    I think it's nearly unreadable. No wonder you can't see what's wrong. Neither can anyone else!

    Here's an example.

    Code: [Select]
    if not exist "%MEDIA%\%%~xF\%%~nF(!NUM!)%%~xF" (ATTRIB -H -S -A -R "%%F" & copy "%%F" "%MEDIA%\%%~xF\%%~nF(!NUM!)%%~xF" & ECHO MOVED "%%F" to "%MEDIA%\%%~xF\%%~nF(!NUM!)%%~xF") else (
    Why did you write it like that?

    gumbaz

      Topic Starter


      Intermediate

      Re: File Type Organizer..??
      « Reply #17 on: February 01, 2009, 05:56:31 PM »
      Code: [Select]
      if not exist "%MEDIA%\%%~xF\%%~nF(!NUM!)%%~xF" (ATTRIB -H -S -A -R "%%F" & copy "%%F" "%MEDIA%\%%~xF\%%~nF(!NUM!)%%~xF" & ECHO MOVED "%%F" to "%MEDIA%\%%~xF\%%~nF(!NUM!)%%~xF") else (
      Whats so unreadable about it exactly..??
      I understand what its suppose to do, but maybe i coded it wrong..
      What do you see thats wrong with it exactly..??

      BC_Programmer


        Mastermind
      • Typing is no substitute for thinking.
      • Thanked: 1140
        • Yes
        • Yes
        • BC-Programming.com
      • Certifications: List
      • Computer: Specs
      • Experience: Beginner
      • OS: Windows 11
      Re: File Type Organizer..??
      « Reply #18 on: February 01, 2009, 06:05:25 PM »
      I think the main preventer of readability is the unnecessary use of ampersands to concatenate commands on single lines for no reason at all.
      I was trying to dereference Null Pointers before it was cool.

      gumbaz

        Topic Starter


        Intermediate

        Re: File Type Organizer..??
        « Reply #19 on: February 01, 2009, 06:19:23 PM »
        so how would i recode it properly then..??

        BC_Programmer


          Mastermind
        • Typing is no substitute for thinking.
        • Thanked: 1140
          • Yes
          • Yes
          • BC-Programming.com
        • Certifications: List
        • Computer: Specs
        • Experience: Beginner
        • OS: Windows 11
        Re: File Type Organizer..??
        « Reply #20 on: February 01, 2009, 08:41:46 PM »
        so how would i recode it properly then..??

        put each line on a separate line.
        I was trying to dereference Null Pointers before it was cool.

        gumbaz

          Topic Starter


          Intermediate

          Re: File Type Organizer..??
          « Reply #21 on: February 02, 2009, 06:16:08 PM »
          what, you mean like this..??

          Code: [Select]
          CD /D C:\FILES
          set MEDIA=C:\[-MEDIA-]
          setlocal enabledelayedexpansion
          if not exist %MEDIA% MD %MEDIA%
          for /f "delims=" %%F in ('DIR /AH /AS /AR /AA /B /S') do (
          set /a NUM=1
          if not exist "%MEDIA%\%%~xF" MD "%MEDIA%\%%~xF"
          if not exist "%MEDIA%\%%~xF\%%~nxF" (ATTRIB -H -S -A -R "%%F"
          copy "%%F" "%MEDIA%\%%~xF"
          ECHO MOVED "%%F" to "%MEDIA%\%%~xF\%%~nxF") else (
          :TOP
          ECHO %NUM%
          ECHO %%F
          if not exist "%MEDIA%\%%~xF\%%~nF(!NUM!)%%~xF" (ATTRIB -H -S -A -R "%%F"
          copy "%%F" "%MEDIA%\%%~xF\%%~nF(!NUM!)%%~xF"
          ECHO MOVED "%%F" to "%MEDIA%\%%~xF\%%~nF(!NUM!)%%~xF") else (
          set /a NUM+=1 & goto TOP)
          )
          DEL /F /Q "%%F"
          )

          gumbaz

            Topic Starter


            Intermediate

            Re: File Type Organizer..??
            « Reply #22 on: February 03, 2009, 12:23:30 AM »
            its still not working for me after it copies over "FILE(1).EXT"

            File not found - %F
            The system cannot find the file specified.


            Whats going wrong..??

            Dias de verano

            • Guest
            Re: File Type Organizer..??
            « Reply #23 on: February 03, 2009, 12:27:37 AM »
            Look carefully at your braces.

            gumbaz

              Topic Starter


              Intermediate

              Re: File Type Organizer..??
              « Reply #24 on: February 03, 2009, 12:59:33 AM »
              im blind, please just tell me where its wrong.. i spent too much time conjuring up my 2 brain cells on this already...

              Dias de verano

              • Guest
              Re: File Type Organizer..??
              « Reply #25 on: February 03, 2009, 01:09:51 AM »
              You are using braces (like this
              to create blocks for if) but (
              you are also creating filenames with (!braces!) in them within those blocks)

              Which breaks the code

              Thats what I am guessing

              because your code is so horrible to look at.

              What does your code do when it finds a directory name?

              gumbaz

                Topic Starter


                Intermediate

                Re: File Type Organizer..??
                « Reply #26 on: February 03, 2009, 01:37:15 AM »
                it doesn't pick up directory names because of this ('DIR /AH /AS /AR /AA /B /S')
                maybe thats the prob..??
                i want it to pick up every file with any attribute possible..

                Dias de verano

                • Guest
                Re: File Type Organizer..??
                « Reply #27 on: February 03, 2009, 01:41:39 AM »
                DIR /A-D /AH /AS /AR /AA /B /S

                gumbaz

                  Topic Starter


                  Intermediate

                  Re: File Type Organizer..??
                  « Reply #28 on: February 03, 2009, 01:51:05 AM »
                  still aint working for some reason..??
                  it works fine up untill the part when it has to copy over "FILE(2).EXT"
                  it copies over "FILE(1).EXT" just fine but "FILE(2).EXT" just havin it man..??

                  trie it out..
                  put any file type into c:\files then run the bat
                  copy back the same file to c:\files and run the bat again it gets copied over as "FILE(1).EXT"
                  copy back the file once more & run the bat again, and thats when the "File Not Found Error" occurs...

                  BC_Programmer


                    Mastermind
                  • Typing is no substitute for thinking.
                  • Thanked: 1140
                    • Yes
                    • Yes
                    • BC-Programming.com
                  • Certifications: List
                  • Computer: Specs
                  • Experience: Beginner
                  • OS: Windows 11
                  Re: File Type Organizer..??
                  « Reply #29 on: February 03, 2009, 02:23:36 AM »
                  you are also creating filenames with (!braces!) in them within those blocks)

                  the braces should be escaped I think.
                  I was trying to dereference Null Pointers before it was cool.