Hopefully a straightforward one?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Kaarthuul
Posts: 4
Joined: 14 Sep 2021 01:25

Hopefully a straightforward one?

#1 Post by Kaarthuul » 14 Sep 2021 02:09

Hi all,

I get sent a zip file from my design team that contains images in several different languages. Each language has its own folder and in that folder is a folder called "images"

i.e. EN/images/
FR/images/
SE/images/ etc.

Once extracted I need a batch file to speed up the process of getting these images to the correct place.

For each folder I have to rename the images folder to the equivalent language (usually the same but for some reason Sweden is different)

i.e. EN/en
FR/fr
SE/sv

These renamed folders then have to be uploaded to a numbered folder on a network drive (filecopy) which then uploads these images to the webserver.

I need to capture the 4 digit number from the user create the folder using that number i.e. Y:\Images\email\1234 and then copy all the renamed folders above into it. Ideally with a pause between each folder as the filecopy upload can be temperamental.

Hope you can help, info file attached, thanks.
Attachments
info.txt
(980 Bytes) Downloaded 8 times

Aacini
Expert
Posts: 1712
Joined: 06 Dec 2011 22:15
Location: México City, México

Re: Hopefully a straightforward one?

#2 Post by Aacini » 14 Sep 2021 10:05

You'll get more feedback if you add details and examples to your question. Did you read the very first post in this forum?

Antonio

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

Re: Hopefully a straightforward one?

#3 Post by Squashman » 14 Sep 2021 10:25

Kaarthuul wrote:
14 Sep 2021 02:09
For each folder I have to rename the images folder to the equivalent language (usually the same but for some reason Sweden is different)

i.e. EN/en
FR/fr
SE/sv
That looks like you are renaming the Language Folder and not the images folder.

Kaarthuul
Posts: 4
Joined: 14 Sep 2021 01:25

Re: Hopefully a straightforward one?

#4 Post by Kaarthuul » 14 Sep 2021 11:33

I thought I had explained it quite clearly, I shall simplify it even more for you:

Please input number: (user inputs a number) e.g. 1234

Make folder Y:\Images\email\1234

rename folder "images" in the EN folder to en and copy this en folder and its contents to the newly created 1234 folder

rename folder "images" in the FR folder to fr and copy this fr folder and its contents to the newly created 1234 folder

rename folder "images" in the SE folder to sv and copy this sv folder and its contents to the newly created 1234 folder

etc. etc. etc. for 13 different countries (only put 3 as I assume I can copy the code and adjust for the rest)

Perhaps this is too far below your level here for you to be able to help?

I've just written an old school file to do some of it.

CD EN
Rename images en
CD ..
(repeated for the other 12)

I will just have to manually create the network folder and drag and drop each renamed folder across, thanks anyway :(

Aacini
Expert
Posts: 1712
Joined: 06 Dec 2011 22:15
Location: México City, México

Re: Hopefully a straightforward one?

#5 Post by Aacini » 14 Sep 2021 23:24

Try this:

Code: Select all

@echo off
setlocal

rem User inputs a number
set /P "number=Please input number: "

rem Make folder
md Y:\Images\email\%number%

rem Rename folder "images" in 13 different 2-letters countries to lowcase country
rem and copy this lowcase country folder to previously created folder
for %%a in (en fr se etc ...) do (
   ren %%a\images %%a
   xcopy /E /I %%a\%%a Y:\Images\email\%number%\%%a
   pause
)

rem Fix the special case
ren SE\se sv
ren Y:\Images\email\%number%\se sv
Antonio

Kaarthuul
Posts: 4
Joined: 14 Sep 2021 01:25

Re: Hopefully a straightforward one?

#6 Post by Kaarthuul » 15 Sep 2021 02:02

Perfect, thank you :)

Kaarthuul
Posts: 4
Joined: 14 Sep 2021 01:25

Re: Hopefully a straightforward one?

#7 Post by Kaarthuul » 15 Sep 2021 02:18

Just had a thought, sometimes there are a few countries missing. This still works fine, I just get an error on the screen to say folder does not exist and it carries on to the next. Is there any way to jump missing folders? TIA

Post Reply