Moving Folder cyclic copy error

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
cumhur_28
Posts: 22
Joined: 22 Jul 2014 13:03

Moving Folder cyclic copy error

#1 Post by cumhur_28 » 17 Nov 2014 03:26

Hi;
I have folders like that. and there are not empty. it contains pdf files. for example this files in c:\test
397700101201410
397200101201410
407700101201410
417700101201410

i created 2 folders in c:\test like "1blok and 2blok"

i want to move 397700101201410, 397200101201410 files to 1blok ---------------this folders contains pdf files.
i want to move 407700101201410, 417200101201410 files to 2blok ---------------this folders contains pdf files.


is it possible to do that.

Thanx

Cumhur

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

Re: Moving Folder cyclic copy error

#2 Post by foxidrive » 17 Nov 2014 04:45

cumhur_28 wrote:i want to move 397700101201410, 397200101201410 files to 1blok ---------------this folders contains pdf files.
i want to move 407700101201410, 417200101201410 files to 2blok ---------------this folders contains pdf files.

It seems as though you haven't given full details of the task.

This solves the task as you have specified.

Code: Select all

@echo off
move 397700101201410 1blok
move 397200101201410 1blok
move 407700101201410 2blok
move 417200101201410 2blok

cumhur_28
Posts: 22
Joined: 22 Jul 2014 13:03

Re: Moving Folder cyclic copy error

#3 Post by cumhur_28 » 17 Nov 2014 05:40

foxidrive wrote:
cumhur_28 wrote:i want to move 397700101201410, 397200101201410 files to 1blok ---------------this folders contains pdf files.
i want to move 407700101201410, 417200101201410 files to 2blok ---------------this folders contains pdf files.

It seems as though you haven't given full details of the task.

This solves the task as you have specified.

Code: Select all

@echo off
move 397700101201410 1blok
move 397200101201410 1blok
move 407700101201410 2blok
move 417200101201410 2blok


hi again thanx for your help.
actually last 6 character changes every month and for example nezt month 397200101201411. when i did 3972001012014?? it gaves me syntax error.
How can we solve this problem

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

Re: Moving Folder cyclic copy error

#4 Post by foxidrive » 17 Nov 2014 05:52

cumhur_28 wrote:How can we solve this problem

The actual details of the task are needed to write a script that will work.

If you tell your partner to go to the hardware store and buy you 3 bolts, do you think they will come home with
the 3 different sized bolts that you wanted: two brass ones in metric, and one stainless steel bolt in imperial, all in the right gauge? :D

The same thing applies in writing scripts - all the details are important.

cumhur_28
Posts: 22
Joined: 22 Jul 2014 13:03

Re: Moving Folder cyclic copy error

#5 Post by cumhur_28 » 17 Nov 2014 06:09

foxidrive wrote:
cumhur_28 wrote:How can we solve this problem

The actual details of the task are needed to write a script that will work.

If you tell your partner to go to the hardware store and buy you 3 bolts, do you think they will come home with
the 3 different sized bolts that you wanted: two brass ones in metric, and one stainless steel bolt in imperial, all in the right gauge? :D

The same thing applies in writing scripts - all the details are important.


my friend i have english language problem and i want to explain all the things but my english is not enough to explain that perfectly.


i will explain again

i have folders for this month names are 397200101201410 417200101201410 417700101201410. and each folder (397200101201410 417200101201410 417700101201410) has pdf file. this folders are in c:\. i created 1blok 2blok folder in c:\.
I want 397200101201410 folder move with subfolders to 1blok (c:\1blok) others are two blok.
your first code works BUT next months- folder names will be 397200101201411 417200101201411 417700101201411 then your batch will be useless. HOW CAN WE SOLVE NOW?

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

Re: Moving Folder cyclic copy error

#6 Post by Squashman » 17 Nov 2014 08:27

cumhur_28 wrote:my friend i have english language problem and i want to explain all the things but my english is not enough to explain that perfectly.

Find someone who speaks better English then you to translate or find a website that is in your native language.

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Moving Folder cyclic copy error

#7 Post by ShadowThief » 17 Nov 2014 08:55

Are we messing with this guy or am I seriously the only one who understands what he wants?

C:\ contains four folders that end with YYYYMM timestamps: C:\397700101201410, C:\397200101201410, C:\407700101201410, and C:\417700101201410

The two folders that start with 397700101 and 397200101 need to get copied to C:\test\1blok
The two folders that start with 407700101 and 417700101 need to get copied to C:\text\2blok

cumhur_28
Posts: 22
Joined: 22 Jul 2014 13:03

Re: Moving Folder cyclic copy error

#8 Post by cumhur_28 » 17 Nov 2014 09:16

Squashman wrote:
cumhur_28 wrote:my friend i have english language problem and i want to explain all the things but my english is not enough to explain that perfectly.

Find someone who speaks better English then you to translate or find a website that is in your native language.


i explained very basicly. how can i explain this???? I offered this website lots of person. They are very helpful, etc...
but you are not kind. "find a website that is in your native language" THİS İS NOT KIND"


folder name changes every months
this month--397700101201410,
next month--397700101201411,

when i wrote

Code: Select all

move c:\397700101201410 c:\1blok
this code next month will be useless beacause of the 201411. i have to open and i need to change this code right for 201411

can we use 397700101?????? for this. This is my question or how can we solve?

if you dont understand again change your native language or banned me your choose

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

Re: Moving Folder cyclic copy error

#9 Post by Squashman » 17 Nov 2014 09:31

ShadowThief wrote:Are we messing with this guy or am I seriously the only one who understands what he wants?
Not messing with anyone. I have a hard time translating broken English. Same thing happened when I was in the military. I started in a unit with a bunch of people from the deep south. I live in the northern states. I spent 8 weeks asking these guys to say everything twice because I couldn't understand them.

I am by no means trying to be hurtful to anyone. If I didn't speak English I would definitely try to find a website forum that did speak my language before trying to get help on another forum that didn't speak my native language. That is just me being logical.

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

Re: Moving Folder cyclic copy error

#10 Post by Aacini » 17 Nov 2014 10:21

foxidrive wrote:If you tell your partner to go to the hardware store and buy you 3 bolts, do you think they will come home with the 3 different sized bolts that you wanted: two brass ones in metric, and one stainless steel bolt in imperial, all in the right gauge? :D

The same thing applies in writing scripts - all the details are important.

+1! :D

Squashman wrote:I am by no means trying to be hurtful to anyone. If I didn't speak English I would definitely try to find a website forum that did speak my language before trying to get help on another forum that didn't speak my native language. That is just me being logical.

Or bought buy a good yourLanguage-English translator device, like me. Translating web tools are not good; I bought a Casio EW-S2000 and works pretty well!.

EDIT: For example, I frequently made mistakes with the verb tenses, but I am pretty sure that most of my post are understandeable!

Antonio

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: Moving Folder cyclic copy error

#11 Post by Compo » 17 Nov 2014 11:42

ShadowThief wrote:Are we messing with this guy or am I seriously the only one who understands what he wants?

The task as given suggests a folder, (C:\test), containing six folders, (397700101201410, 397200101201410, 407700101201410, 417700101201410, 1blok & 2blok).
If the intention is to simply move two into one and the other two into another then a simple one movement mouse drag and drop in explorer is the most efficient way. Hence the reason it is believed that the task is not full explained.

cumhur_28
Posts: 22
Joined: 22 Jul 2014 13:03

Re: Moving Folder cyclic copy error

#12 Post by cumhur_28 » 17 Nov 2014 13:00

nevermind guys. take care yourself.


bye

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Moving Folder cyclic copy error

#13 Post by Ed Dyreen » 17 Nov 2014 13:45

cumhur_28 wrote:can we use 397700101?????? for this. This is my question or how can we solve?

Code: Select all

::----------------------------------------------------------------------------------------------------------------
:: - Looping through dirs or files with /d /r
::----------------------------------------------------------------------------------------------------------------
:: (
   :: Note that for options require immediate expansion of variables !

   :: dirs
   :: (
      echo. &echo. dir absolute
      for /d            %%? in ("%~dp0*")   do echo.%%?

      echo. &echo. dir absolute, recursive
      for /d /r "%~dp0" %%? in ("*")        do echo(%%?

      echo. &echo. dir relative to active directory
      for /d            %%? in ("*")        do echo.%%?
   :: )

   :: files
   :: (
      echo. &echo. file absolute
      for               %%? in ("%~dp0*.*") do echo.%%?

      echo. &echo. file absolute, recursive
      for    /r "%~dp0" %%? in ("*.*")      do echo(%%?

      echo. &echo. file relative to active directory
      for               %%? in ("*.*")      do echo.%%?
   :: )
:: )
::----------------------------------------------------------------------------------------------------------------
assume I have a folder "folderA" on drive C and want to move all files that match expression "397700101??????.PDF" to folder "folderB". from the information above, let's choose absolute file enumeration.

Code: Select all

echo. &echo. file absolute
for %%? in ("C:\folderA\397700101??????.PDF") do echo.%%?
pause
what the above code does is printing all files that match the expression "397700101??????.PDF" on the console. let's try a hypothetical move of all files matching "*.*" in current directory..

Code: Select all

@echo off

set "$srcDir=%~dp0"
set "$trgDir=C:\NEW\"

for %%? in ( "%$srcDir%*.*" ) do (

     set "$srcFile=%%?"
     setlocal enableDelayedExpansion
     set "$trgFile=!$srcFile:%$srcDir%=%$trgDir%!"
     echo(!$srcFile!
     echo(!$trgFile!
     endlocal
)
notice the command setlocal enableDelayedExpansion?, it allows processing fileNames that have special characters in them like exclamation marks, you won't need it, i used it merely because my test dir containes exclamation marks. a list of matches and their new hypothetical locations is printed on the console..

Code: Select all

...
Z:\ED\VIP\PROJ\dev\doskit\doskitXP32x86 v20140429\Hello world !\compare1.TXT
C:\NEW\compare1.TXT
Z:\ED\VIP\PROJ\dev\doskit\doskitXP32x86 v20140429\Hello world !\compare2.TXT
C:\NEW\compare2.TXT
Z:\ED\VIP\PROJ\dev\doskit\doskitXP32x86 v20140429\Hello world !\test.CMD
C:\NEW\test.CMD
...
let's try moving all files matching expression "397700101??????.PDF" in "C:\folderA\" to "C:\folderB\"..

Code: Select all

@echo off

set "$srcDir=C:\folderA\"
set "$trgDir=C:\folderB\"
md "%$trgDir%" :: create target dir
for %%? in ( "%$srcDir%397700101??????.PDF" ) do (

     set "$srcFile=%%?"
     setlocal enableDelayedExpansion
     set "$trgFile=!$srcFile:%$srcDir%=%$trgDir%!"
     echo(^<^<!$srcFile!
     echo(^>^>!$trgFile!
     move /Y "!$srcFile!" "!$trgFile!"
     endlocal
)
echo(that's all there is to it :^)
pause
ps; if you add country information in your profile, users can guess which languages you understand properly. if it's mainly English, i see no harm in writing a few non-english comments. i sometimes add them myself to make sure i am understood.

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

Re: Moving Folder cyclic copy error

#14 Post by foxidrive » 17 Nov 2014 20:02

ShadowThief wrote:Are we messing with this guy or am I seriously the only one who understands what he wants?


What he has stated is quite probably not what he is actually doing - one very big clue is that the thread subject mentions a cyclic copy error and he didn't mention that at all in his question.

If you look at previous posts of cumhur_28 you will see that he doesn't give actual details of his tasks,
and that is fine if you want to reply to the question as it is posed, but I get no satisfaction in providing an answer
and the OP tells you "it doesn't work" and it turns out that the task is not as they have stated.

Check out what happened earlier in this thread when I give him code. It was clear that it wasn't the actual task.

Post Reply