Stephanie
Stephanie

Reputation: 13

Can use commands at cmd prompt but can't create a *.bat file with it

I was successfully searching the web for a way to create a new folder containing ALL the .otf and .ttf files located in a different folder with subdirectories (one folder for each font, a total of 24 subfolders).

I used this:

for /r %x in (*.ttf, *.otf) do copy "%x" G:\dropbox\9mediendesignfachfrau\fonts\allezam\ /y

When I open cmd,

C:...>G:
G:...>cd \dropbox\9mediendesignfachfrau\fonts
G:...>for /r %x in (*.ttf, *.otf) do copy "%x" G:\dropbox\9mediendesignfachfrau\fonts\allezam\ /y

and enter, everything works fine.

I tried pasting that into a .bat file located in the \fonts\ folder and tried starting it. cmd popped up and closed immediately, nothing else happened.

Could you help me finding my mistake?

It's still less work entering every line in cmd, press enter, enter the next line and so on than installing every single font manually but I'm quite lazy so I prefer a single double-click on a .bat file :P

Upvotes: 1

Views: 68

Answers (1)

Hackoo
Hackoo

Reputation: 18857

When you use it in a batch file, the percent sign must be double,so,%x must be changed to %%x and your code looks like this :

@echo off
for /r %%x in (*.ttf, *.otf) do copy "%%x" G:\dropbox\9mediendesignfachfrau\fonts\allezam\ /y
pause

Upvotes: 2

Related Questions