[SOLVED] - 3 Scripts to save me days of work (again)

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Andrius
Posts: 37
Joined: 26 Jun 2012 15:15

[SOLVED] - 3 Scripts to save me days of work (again)

#1 Post by Andrius » 16 Aug 2012 15:17

Script 1:
I need a script to be placed in master folder and when run the script will drill through every folder within the master seeking out folders with the names "source" "animation" and "export" and delete these folders and anything within these folders yet leave any folders that are not called "source" "animation" & "export" alone.

Script 2:
Again place a script in a master folder and when run it drills through the substructures looking at every folder AND file for spaces in filenames. If it finds a space then remove said space in the file or folder name

Script 3:
Again place a script in a master folder and when run it drills through the substructures looking into any folder called "model" and verifying that one of the 4 filetypes are present. If the folder does not contain either .ma .mb .max or .obj then create a text file output so that I can go look into these manually.
Last edited by Andrius on 16 Aug 2012 15:53, edited 1 time in total.

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: [Request] - 3 Scripts to save me days of work (again)

#2 Post by abc0502 » 16 Aug 2012 15:23

in script2 remove space as delete or replace with _

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: [Request] - 3 Scripts to save me days of work (again)

#3 Post by abc0502 » 16 Aug 2012 15:29

UPDATED

Script 1

Code: Select all

@Echo off
CLS
For /F "tokens=*" %%A in ('Dir /B /S /A:D *.*') Do (
   IF "%%~nA" == "source" RMDIR /S /Q "%%A"
   IF "%%~nA" == "animation" RMDIR /S /Q "%%A"
   IF "%%~nA" == "export" RMDIR /S /Q "%%A"
)
pause


Script 2
This was posted before Here

Code: Select all

@Echo off
CLS
SETLOCAL ENABLEDELAYEDEXPANSION

for /f "delims=" %%A in ('"dir /b /s|sort /r"') do (
    set "f=%%~nxA"
    set "f=!f: =!"
    if "%%~nxA" NEQ "!f!" (
        cd "%%~dpA"
        ren "%%~nxA" "!f!"
    )
)
pause


Script 3

Code: Select all

@Echo off
CLS
set "location=%~dp0"
For /F "tokens=*" %%A in ('Dir /B /S /A:D *.*') Do (
   IF /i "%%~nA" == "Model" (
      set "curr=%%~sdpnA"
      pushd %%~sdpnA
         IF not exist "*.ma" ( Call :report ma )
         IF not exist "*.mb" ( Call :report mb )
         IF not exist "*.obj" ( Call :report obj )
         IF not exist "*.max" ( Call :report max )
      popd
   )
)

pause
:report
(
   echo.%curr%
   echo.MissingFileType: %1
   echo.
)>>"%location%\MissingFiles.log"


In this batch a file will be created in the main folder where the batch is, and contain the location and the file type that is missing.

Just Copy the location and past in the windows explorer url and hit enter and you will get to the folder

If you find a location but no file type that mean there is no missing files in that folder, you can ignore it
Last edited by abc0502 on 16 Aug 2012 16:45, edited 5 times in total.

Andrius
Posts: 37
Joined: 26 Jun 2012 15:15

Re: [Request] - 3 Scripts to save me days of work (again)

#4 Post by Andrius » 16 Aug 2012 15:31

abc0502 wrote:in script2 remove space as delete or replace with _


remove spaces. In our engine we use _ to seperate categories in a way (hard to explain) but basically just looking to remove spaces with this one

Andrius
Posts: 37
Joined: 26 Jun 2012 15:15

Re: [Request] - 3 Scripts to save me days of work (again)

#5 Post by Andrius » 16 Aug 2012 15:39

abc0502 wrote:Script 1

Code: Select all

@Echo off
CLS
For /F "tokens=*" %%A in ('Dir /B /S /A:D *.*') Do (
   IF "%%~nA" == "source" RMDIR /S /Q "%%A"
   IF "%%~nA" == "animation" RMDIR /S /Q "%%A"
   IF "%%~nA" == "export" RMDIR /S /Q "%%A"
)
pause


Script 2
This was posted before Here

Code: Select all

@Echo off
CLS
SETLOCAL ENABLEDELAYEDEXPANSION

for /f "delims=" %%A in ('"dir /b /s|sort /r"') do (
    set "f=%%~nxA"
    set "f=!f: =!"
    if "%%~nxA" NEQ "!f!" (
        cd "%%~dpA"
        ren "%%~nxA" "!f!"
    )
)
pause



Thank you thank you!

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: [SOLVED] - 3 Scripts to save me days of work (again)

#6 Post by Squashman » 16 Aug 2012 16:21

Pretty sure if you searched the forums you would have found your solutions. We did Script 2 just a few weeks ago. Pretty sure we did script 1 not to long ago as well. And well you could always make an attempt at writing them yourself and actually learning how to do it instead of someone always giving you the fish.

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: [SOLVED] - 3 Scripts to save me days of work (again)

#7 Post by abc0502 » 16 Aug 2012 17:02

All Files up

Andrius
Posts: 37
Joined: 26 Jun 2012 15:15

Re: [SOLVED] - 3 Scripts to save me days of work (again)

#8 Post by Andrius » 16 Aug 2012 17:04

abc0502 wrote:All Files up


Thank you soooo much abc!

Andrius
Posts: 37
Joined: 26 Jun 2012 15:15

Re: [SOLVED] - 3 Scripts to save me days of work (again)

#9 Post by Andrius » 16 Aug 2012 17:06

Squashman wrote:Pretty sure if you searched the forums you would have found your solutions. We did Script 2 just a few weeks ago. Pretty sure we did script 1 not to long ago as well. And well you could always make an attempt at writing them yourself and actually learning how to do it instead of someone always giving you the fish.


Im actually an artist on this project which a bit of tech know how and I pick things up as I go.. I just dont have the time to sit down and straight up learn this stuff yet. Today yes I agree I should have been more thorough and searched. it is a crazy day here and I needed a solution quickly and thankfully you guys were able to assist yet again.

trust me it is really appreciated and this should be one of the last things I ask for help with.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: [SOLVED] - 3 Scripts to save me days of work (again)

#10 Post by Squashman » 16 Aug 2012 17:12

Andrius wrote:Im actually an artist on this project which a bit of tech know how and I pick things up as I go.. I just dont have the time to sit down and straight up learn this stuff yet. Today yes I agree I should have been more thorough and searched. it is a crazy day here and I needed a solution quickly and thankfully you guys were able to assist yet again.

trust me it is really appreciated and this should be one of the last things I ask for help with.

Then shouldn't you have a dedicated tech person for this project?
I am just one of those people who believe in passing it on. If people help you in a community you should also give back to that community. Just my philosophy.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: [SOLVED] - 3 Scripts to save me days of work (again)

#11 Post by foxidrive » 16 Aug 2012 18:46

Squashman wrote:I am just one of those people who believe in passing it on. If people help you in a community you should also give back to that community. Just my philosophy.


I like the thought that they will give back to this, or another community.

Not everyone is suited for writing scripts but they can use a ready made batch file. So if they give back in other ways to another community then that is just as good IMHO.

Post Reply