# How to finis batch script?

February 7, 2012 at 19:13:30
Specs: Windows XP
 Regards to everyone.I have the following folder structure: Folder "TEST" and inside that folder three subfolders "import", "export" and "acitve"In folder "import" are images I've downloaded from the Internet and sort in separated folder. Example - folder "Dogs" have 8 picture....."Cats" have 4 picture and so on. Every folder have diferent number of pictures. Numbers of folder in "import" is always changing.So far I have managed the following:1. I resize all folders in "import" to 01,02,03.....X ...to know the order in which I work.2. Copy EMPTY folder structure without files from "import" to folder "export". I use command: xcopy /T /E /Q /Y "C:\TEST\import" "C:\TEST\export" ...and it works3. If folder "01" exist in folder "import", copy all files inside folder "01" to folder "active". I use command: IF EXIST "C:\TEST\import\01" xcopy /Q /Y "C:\TEST\import\01*.*" "C:\TEST\active\" ...and it works4. Delete folder "01" inside "import". I use command: RMDIR /S /Q "C:\TEST\import\01" ...and it worksAfter step "4" I use image editor to auto resize picture.5. Copy resize pictures from folder "active" to folder "01" in "exported". I use command: xcopy /Q /Y "C:\TEST\active" "C:\TEST\exported\01" ...and it works6. Delete all pictures inside folder "active". I use command: DEL /Q "C:\TEST\active" ...and it works-How to create loop or whatever, that will allow me when I repeat all stpes again....to check folder 02,03,04...folder "X" and so on until it reaches the end automaticli? This applies to step 3?-When I finish three or four folders I manualy rename all folders in "export"....."01" to "Dog"...."02" to "Cats".....X to X and so on. Is there an easier way?

See More: How to finis batch script?

#1
February 9, 2012 at 09:36:03
 flatron,This is possible. When you say you resize folders in import, did you mean you renamed them?What we can do here is use a dir statement to create a list of the folders in import. Then we can loop through that list and execute each of your commands on each of the folders.@echo offsetlocalREM most of this batch is the commands you listed in your original postxcopy /T /E /Q /Y "C:\TEST\import" "C:\TEST\export"REM this is the dir statement that lists the contents of importdir /b c:\test\import > import_contents.tmpREM This is the for loop that is replacing your if existfor /f %%a in (import_contents.tmp) do ( xcopy /Q /Y "c:\test\import\%%a\*.*" "c:\test\active\" RMDIR /S /Q "C:\TEST\import\%%a" xcopy /Q /Y "C:\TEST\active" "C:\TEST\exported\%%a" DEL /Q "C:\TEST\active")endlocal

Report •
Related Solutions
{"extraction_info": {"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.9038839340209961, "perplexity": 24809.1124217985}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.3, "absolute_threshold": 20, "end_threshold": 15, "enable": false}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2018-13/segments/1521257648003.58/warc/CC-MAIN-20180322205902-20180322225902-00017.warc.gz"}