Jump to content

Problem making a Batchfile with Variables


GoFrag

Recommended Posts

Hello,

I will making a btachfile thats copying Files from Drive H:\

to Drive d: .

Bud i will that the Path is dependence from Date

so the script copied The Files

from H:\DCIM\e4456\*.* to d:\eigene Dateien\bilder\%Date in YYMMDD Format%

Bud we can a make it?

Gofrag

Link to comment
Share on other sites


ich denke, daB es helfen wurde, wenn sie es auf Deutsch schreiben. :)

hm this far i know with german

so u want to copy picture files having them with dates instead of the file name itself (which i think would be dcim) sony right?

i think u might need to rename them first with some sort of batch renamer.

Link to comment
Share on other sites

This thread i have found...

bud I will make a folder in the Format yymmdd not dd.mm.yyyy

so windows will not correctly sort the folders...

And make this folder to a Variable

So i can use the Following command:

xcopy32 h:\dcim\e345\*.* d:\eigene dateien\bilder\%Currentday%

what i will is that the Foldersname will correctly sortet:

040409

040410

040411

040509

050409

Can anyone help me..?

Thanks for your helps

cu

Gofrag

Sorry about my bad english...

Link to comment
Share on other sites

And this is the Result:

==============================================

@echo off

set x=%date%

set yy=%x:~8,2%

set mm=%x:~3,2%

set dd=%x:~0,2%

set CURRENTDATE=%yy%%mm%%dd%

If exist l:\DCIM\100MLT32 set Kamera=l:\DCIM\100MLT32

If exist k:\DCIM\100MLT32 set Kamera=k:\DCIM\100MLT32

If exist j:\DCIM\100MLT32 set Kamera=j:\DCIM\100MLT32

If exist i:\DCIM\100MLT32 set Kamera=i:\DCIM\100MLT32

If exist h:\DCIM\100MLT32 set Kamera=h:\DCIM\100MLT32

If exist g:\DCIM\100MLT32 set Kamera=g:\DCIM\100MLT32

If exist f:\DCIM\100MLT32 set Kamera=f:\DCIM\100MLT32

If exist e:\DCIM\100MLT32 set Kamera=e:\DCIM\100MLT32

If exist d:\DCIM\100MLT32 set Kamera=d:\DCIM\100MLT32

Set Ladung=L1

IF exist d:\eigene~1\bilder\%CURRENTDATE%\L1 set ladung=L2

IF exist d:\eigene~1\bilder\%CURRENTDATE%\L2 set ladung=L3

IF exist d:\eigene~1\bilder\%CURRENTDATE%\L3 set ladung=L4

IF exist d:\eigene~1\bilder\%CURRENTDATE%\L4 set ladung=L5

IF exist d:\eigene~1\bilder\%CURRENTDATE%\L5 set ladung=L6

IF exist d:\eigene~1\bilder\%CURRENTDATE%\L6 set ladung=L7

IF exist d:\eigene~1\bilder\%CURRENTDATE%\L7 set ladung=L8

IF exist d:\eigene~1\bilder\%CURRENTDATE%\L8 set ladung=L9

IF exist d:\eigene~1\bilder\%CURRENTDATE%\L9 set ladung=L10

d:

cd\eigene~1\bilder

md %yy%%mm%%dd%

xcopy %Kamera%\*.jpg d:\eigene~1\bilder\%CURRENTDATE%\%ladung% /V /C /I /F

DEL %KAMERA%\*.* /F /S /Q

exit

==================================================

Thanks for Help!

cu

GoFrag

Link to comment
Share on other sites

:rolleyes::)

Captain, i have a Problem....

This Script functionally great..with Winxp...

bud under Win98SE....No Way....

The Second Line is the Problem...

Set x=%date%

This will not Work

Give it a Alternative?

cu

GoFrag

Link to comment
Share on other sites

If DATE/T is accepted:

SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
SET yy=
FOR /F "USEBACKQ TOKENS=1-3 DELIMS=/" %i IN (`DATE /T`) DO (
       SET dd=%i
       SET mm=%j
       SET yyyy=%k
       SET yy=%yyyy:~2,2%
)
SET yymmdd=%yy%%mm%%dd%

set yymmdd
echo %yymmdd%

Otherwise:

First, create an empty file CRLF.TXT like:

COPY CON: CRLF.TXT
^Z (or Function key F6)

then the code will be (replace "La" by the 1st word of the line where the date is displayed when typing DATE, probably "The" in English) :

DATE >CURDATE.TXT <CRLF.TXT
SET yy=
FOR /F "TOKENS=1,6-8 DELIMS=:/ " %i IN (CURDATE.TXT) DO (
   IF "%i" == "La" (
       SET dd=%j
       SET mm=%k
       SET yyyy=%l
       SET yy=%yyyy:~-2%
   )
)
SET yymmdd=%yy%%mm%%dd%

set yymmdd
echo %yymmdd%

Link to comment
Share on other sites

Hello Mdes,

Thanks for your Help!

Also:

I have no Idee how this work, bud i will do what you say....

Also Date /T is not accepted

The Second: under Winxp: %i can not be used at this point (Translated from Didaktisch).

and under Win98SE stops the Prozess so I must break up...

the CRLF.txt file i have created empty

What i do wrong?

cu

GoFrag

Link to comment
Share on other sites

Sorry, but I do not understand what you mean :)

  • If "DATE/T" is working under Win98, you should use only the 1st CODE (there is no need to create the empty file CRLF.TXT)
  • If "DATE/T" is not working under Win98, you should:
    • Create the empty file CRLF.TXT
    • Execute the last CODE

BUT: You should double the "%" to "%%" if you insert the code in a Batch (.CMD or .BAT) file.

Link to comment
Share on other sites

  • 9 months later...

With WinXP, instead of `DATE /T`, you could also use '%DATE%'.

(1) Beware backquotes and single quotes!

(2) Check the format given by DATE/T to see which is the format: mm/dd/yyyy or dd/mm/yyyy)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...