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

Author Topic: *Solved* (CD Rules) Changing the file type of files in subfolders  (Read 14806 times)

0 Members and 1 Guest are viewing this topic.

Sir.Laggalot

  • Guest
How would i go about making a batch file rename the file type for files in subfolders of the folder the .bat is in.
I am using Windows XP Home, and i really would like to not use anything that has to be downloaded.

The point of this program is to Change the type so they are unreadable and hide images of the .jpg, .gif, and .png type

At this point it works perfectly for the folder it is in, but not the subfolders. I do know how to hide subfolders content but not how to change their file types.

I have been messing with Batch programing since yesterday so if any one has any other suggestions i would really like them.

my code so far is such...

@ ECHO OFF
title Image Concealer
REM Sir.Laggalot

IF EXIST *.jpg. GOTO HIDE
 IF EXIST *.gif. GOTO HIDE
  IF EXIST *.png. GOTO HIDE
   IF EXIST *.mp3. GOTO FIX
    IF EXIST *.mp4. GOTO FIX
     IF EXIST *.avi. GOTO FIX


ECHO.
ECHO ERROR-
ECHO There are no .jpg, .gif, .png, .mp3, .mp4, or .avi files to effect.
ECHO.
ECHO.

PAUSE
GOTO END

:HIDE

rename *.jpg *.mp3
cls
rename *.gif *.mp4
cls
rename *.png *.avi
cls
attrib "./*.mp3" +h
cls
attrib "./*.mp4" +h
cls
attrib "./*.avi" +h
cls

GOTO END

:FIX

attrib "./*.mp3" -h
cls
attrib "./*.mp4" -h
cls
attrib "./*.avi" -h
cls
rename *.mp3 *.jpg
cls
rename *.mp4 *.gif
cls
rename *.avi *.png
cls

:END


All the cls are for making the page continue to look neat for the couple seconds it is up, instead of listing errors for file types that arent there, Like if there are jpgs  but no gifs.
« Last Edit: August 26, 2007, 03:23:36 PM by Sir.Laggalot »

Sir.Laggalot

  • Guest
Re: Changing the file type of files in subfolders
« Reply #1 on: August 25, 2007, 08:30:14 PM »
Oh thought i should state that this will mess up any mp3, mp4, and avi files if used in the same folder with them.

It will hide the images if used and then unhide them if used again

ghostdog74



    Specialist

    Thanked: 27
    Re: Changing the file type of files in subfolders
    « Reply #2 on: August 25, 2007, 08:41:13 PM »
    what exactly are you trying to do.

    Sir.Laggalot

    • Guest
    Re: Changing the file type of files in subfolders
    « Reply #3 on: August 25, 2007, 08:47:21 PM »
    I would like this batch to do what it is doing to its one folder to all of its folder's subfolders.

    updated version (neater)

    @ ECHO OFF
    title Image Concealer
    :: A Sir.Laggalot Creation

    IF EXIST *.jpg. GOTO HIDE
     IF EXIST *.gif. GOTO HIDE
      IF EXIST *.png. GOTO HIDE
       IF EXIST *.mp3. GOTO FIX
        IF EXIST *.mp4. GOTO FIX
         IF EXIST *.avi. GOTO FIX
          ECHO.
          ECHO ERROR-
          ECHO There are no .jpg, .gif, .png, .mp3, .mp4, or .avi files to effect.
          ECHO.
          ECHO.
           PAUSE
            GOTO END
    :HIDE
     REN *.jpg *.mp3
      ATTRIB "./*.mp3" +h
       REN *.gif *.mp4
        ATTRIB "./*.mp4" +h
         REN *.png *.avi
          ATTRIB "./*.avi" +h
           GOTO END
    :FIX
    ATTRIB "./*.mp3" -h
     REN *.mp3 *.jpg
      ATTRIB "./*.mp4" -h
       REN *.mp4 *.gif
        ATTRIB "./*.avi" -h
         REN *.avi *.png
          GOTO END
    :END

    Sir.Laggalot

    • Guest
    Re: Changing the file type of files in subfolders
    « Reply #4 on: August 25, 2007, 08:51:39 PM »
    How would i go about making a batch file rename the file type for files in subfolders of the folder the .bat is in.

    That is what i am trying to do

    Example would be

    change a .jpg in a subfolder of the folder the bat is in to a .mp3

    patio

    • Moderator


    • Genius
    • Maud' Dib
    • Thanked: 1769
      • Yes
    • Experience: Beginner
    • OS: Windows 7
    Re: Changing the file type of files in subfolders
    « Reply #5 on: August 25, 2007, 09:33:35 PM »
    How would i go about making a batch file rename the file type for files in subfolders of the folder the .bat is in.

    That is what i am trying to do

    Example would be

    change a .jpg in a subfolder of the folder the bat is in to a .mp3

    Why ? ?
    " Anyone who goes to a psychiatrist should have his head examined. "

    Sir.Laggalot

    • Guest
    Re: Changing the file type of files in subfolders
    « Reply #6 on: August 25, 2007, 09:37:30 PM »
    So that they cant be easily read, i often forget to make my hidden files invisible again and i have littles who use my computer.

    Needless to say, i would rather them not get into some files.

    Changing a .jpg to an mp3 makes it unreadable until you switch it back.

    I will eventually switch mp3, mp4, and avi to a different less used filename to prevent damage to my music and videos.

    Sir.Laggalot

    • Guest
    Re: Changing the file type of files in subfolders
    « Reply #7 on: August 25, 2007, 09:38:30 PM »
    I am sure there are better ways of hiding them but this is my first .bat program and so it has become sort of a pet project now.

    Dusty



      Egghead

    • I could if she would, but she won't so I don't.
    • Thanked: 75
    • Experience: Beginner
    • OS: Windows XP
    Re: Changing the file type of files in subfolders
    « Reply #8 on: August 25, 2007, 09:41:56 PM »
    Don't you just love those 'pet projects'?

    If you know the names of the subfolders can you not use CD and CALL the Image Concealer .bat file?

    Good luck
    One good deed is worth more than a year of good intentions.

    Sir.Laggalot

    • Guest
    Re: Changing the file type of files in subfolders
    « Reply #9 on: August 25, 2007, 09:48:35 PM »
    I have been using bat since yesterday, i really don't know that much (only other languages i have used is some html and a little java).

    I was hoping for a way to open it with variables so i dont have to copy paste all directories, but if there is no way for it to find them itself, i could do that.

    And example of what i would enter for the call would be help full

    C:\Documents and Settings\Admin\Desktop\Batch Programing\Test Environment\Test Primary\Test Secondary

    I have the bat file in the Test Primary folder, and i am looking for it to effect the Test Secondary folder, and any other subfolders in the Primary folder

    Sir.Laggalot

    • Guest
    Re: Changing the file type of files in subfolders
    « Reply #10 on: August 25, 2007, 10:03:41 PM »
    ok so i was looking at a CD info, and i couldnt understand it

    I tried call but instead of it opening the bat in the folder it was in it opened in the folder the master was in.

    I want to have a way to just use the hider in every subfolder of a folder with one launch of a program, i am fine with it making other programs in each of the folders go off too.

    Dusty



      Egghead

    • I could if she would, but she won't so I don't.
    • Thanked: 75
    • Experience: Beginner
    • OS: Windows XP
    Re: Changing the file type of files in subfolders
    « Reply #11 on: August 25, 2007, 10:41:12 PM »
    I can only advise how I would try to achieve, bear in mind that I am basically lazy....

    I have all my .bat files (all seven of them) in a folder named BAT which is in my PATH so I don't have to use the full Path to any .bat file when accessing it.

    So I would create the Image Concealer file and Save it in the Bat folder as say Conceal.bat

    Next I would create another 'master' .bat file which will be used to CD and call Conceal.bat.   Assuming you are first accessing the Command Prompt (CMD.EXE) and are at the C: prompt, and you have a primary directory named Tracks and a sub-directory named Films it would look something like:

    cd tracks                              (default directory is now Tracks)
    call Conceal.bat
    cd Films                                (default directory is now Tracks/Films)
    call Conceal.bat
    cd ..                                      (return to the Films parent directory {Tracks})
    cd NextDirectory                   (default directory is now NextDirectory)

    OK, I agree it's pretty crude - will it work - try it

    The cd commands could be included in Conceal.bat and the file could be run minimized from a desktop shortcut  - there are many methods, the above is just one.

    Good luck

    p.s.  Here are the NT commands CD(ChDir {Change Directory}) is one of them.  If you go with my post above you will have to understand CD, please post back with what you don't understand and one of us will assist.



     



    « Last Edit: August 26, 2007, 04:59:58 PM by Dusty »
    One good deed is worth more than a year of good intentions.

    Sir.Laggalot

    • Guest
    Re: Changing the file type of files in subfolders
    « Reply #12 on: August 25, 2007, 10:44:55 PM »
    kk i will try.

    Sir.Laggalot

    • Guest
    Re: Changing the file type of files in subfolders
    « Reply #13 on: August 25, 2007, 10:53:27 PM »
    Ok, took me a bit to figure it out, but i got it now.

    You're right, it is crude but its pretty much what i thought i would have to do, (still hoping for a way to make it find the .bats so i dont have to enter them in my self).


    -Thank you

    Dusty



      Egghead

    • I could if she would, but she won't so I don't.
    • Thanked: 75
    • Experience: Beginner
    • OS: Windows XP
    Re: Changing the file type of files in subfolders
    « Reply #14 on: August 25, 2007, 11:48:18 PM »

    (still hoping for a way to make it find the .bats so i dont have to enter them in my self).


    Am not sure what this means.  Once the two files are set up there just ain't no more typing to do, you can run them by simply clicking on a desktop icon.

    Ah well, at least you're 75% done

    Good luck
    One good deed is worth more than a year of good intentions.