PC Review


Reply
Thread Tools Rate Thread

How can I rename a directory quickly in a script?

 
 
Todd
Guest
Posts: n/a
 
      17th Oct 2011
Hi Guys,

I have a batch script that rotates directory names.

rename %BkPath%\backup%X% backup%Y%

Problem: I do not seem to just be changing the name of the directory,
I seem to be copying all the contents of the old directory to
the new directory. It works, but it can take up to 20 minutes
as there is a lot of data in each backup set.

Is there a way to just change the name of the directory and avoid
the time delay of all the copying?

Many thanks,
-T

 
Reply With Quote
 
 
 
 
Paul
Guest
Posts: n/a
 
      17th Oct 2011
Todd wrote:
> Hi Guys,
>
> I have a batch script that rotates directory names.
>
> rename %BkPath%\backup%X% backup%Y%
>
> Problem: I do not seem to just be changing the name of the directory,
> I seem to be copying all the contents of the old directory to
> the new directory. It works, but it can take up to 20 minutes
> as there is a lot of data in each backup set.
>
> Is there a way to just change the name of the directory and avoid
> the time delay of all the copying?
>
> Many thanks,
> -T
>


If you do this

rename C:\testdir\test.txt C:\testdir\newname.txt

that can work, because the data clusters are already on the
C: partition, and all that needs correcting, is the path to get
there.

If you do this

rename C:\testdir\test.txt D:\somedir\newname.txt

then that involves two independent partitions, and the only
way to get the data clusters there is by copying them. No
amount of fiddling the path or file pointer info can fix it.
You pay "full price" in that case.

If you had a Partition Manager, and you "merged" two partitions
which were next to one another on the same disk, that might be
an example of "crossing the boundary". I've never done a merge,
and have no idea how it is actually achieved (the mechanics of merging).
But you never know, it might be more economical than a plain copy.
Since it changes the state of the system, it's hardly a replacement
for what you're trying to do.

Paul
 
Reply With Quote
 
Todd
Guest
Posts: n/a
 
      17th Oct 2011
On 10/16/2011 08:44 PM, Paul wrote:
> Todd wrote:
>> Hi Guys,
>>
>> I have a batch script that rotates directory names.
>>
>> rename %BkPath%\backup%X% backup%Y%
>>
>> Problem: I do not seem to just be changing the name of the directory,
>> I seem to be copying all the contents of the old directory to
>> the new directory. It works, but it can take up to 20 minutes
>> as there is a lot of data in each backup set.
>>
>> Is there a way to just change the name of the directory and avoid
>> the time delay of all the copying?
>>
>> Many thanks,
>> -T
>>

>
> If you do this
>
> rename C:\testdir\test.txt C:\testdir\newname.txt
>
> that can work, because the data clusters are already on the
> C: partition, and all that needs correcting, is the path to get
> there.
>
> If you do this
>
> rename C:\testdir\test.txt D:\somedir\newname.txt


The expanded script look like

rename d:\MyBackup\backup1 d:\MyBackups\backup2

I am renaming to the same drive

I am renaming directories, not files. The directories are full
of stuff. Takes about 20 minutes to rename. Bummer.

>
> then that involves two independent partitions, and the only
> way to get the data clusters there is by copying them. No
> amount of fiddling the path or file pointer info can fix it.
> You pay "full price" in that case.
>
> If you had a Partition Manager, and you "merged" two partitions
> which were next to one another on the same disk, that might be
> an example of "crossing the boundary". I've never done a merge,
> and have no idea how it is actually achieved (the mechanics of merging).
> But you never know, it might be more economical than a plain copy.
> Since it changes the state of the system, it's hardly a replacement
> for what you're trying to do.
>
> Paul


 
Reply With Quote
 
Mayayana
Guest
Posts: n/a
 
      17th Oct 2011
I don't have much experience with DOS batch files,
so I don't know if maybe there's a separate problem.
It seems like what you're doing should work OK.
But you might try this in a .vbs file:

Dim FSO, oFol
Set FSO = CreateObject("Scripting.FileSystemObject")
Set oFol = FSO.GetFolder("D:\MyBackup\backup1")
oFol.Name = "backup2"
Set oFol = Nothing
Set FSO = Nothing

I renamed a 767 MB folder instantly with that VBS.
If that doesn't work instantly for you then probably
you've got something interfering. (AV? I don' know.)


 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      17th Oct 2011
Todd wrote:

>
> The expanded script look like
>
> rename d:\MyBackup\backup1 d:\MyBackups\backup2
>
> I am renaming to the same drive
>
> I am renaming directories, not files. The directories are full
> of stuff. Takes about 20 minutes to rename. Bummer.


I'd start by looking here first. This site helped me, when I
was whipping together an MSDOS floppy.

It says "rename" is for files, and "move" is for directories,
whatever that means.

http://www.vfrazee.com/ms-dos/6.22/help/rename.htm

If that isn't it, I'd check to make sure the attempt to "rename",
isn't picking up a script or executable of the same name, from
somewhere in your execution path. Sometimes, when writing scripts,
you give absolute paths for the tools, to prevent surprises. Or,
you define the execution path, local to the script, so the script
doesn't "escape into the woods" :-) Perhaps a built-in command has
priority over a path search, but I don't know enough about your
environment to say what might be the case. I'd just experiment
until I got the right results.

Paul
 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      17th Oct 2011
Todd wrote:

>
> The expanded script look like
>
> rename d:\MyBackup\backup1 d:\MyBackups\backup2
>
> I am renaming to the same drive
>
> I am renaming directories, not files. The directories are full
> of stuff. Takes about 20 minutes to rename. Bummer.


<repost - first one didn't seem to go anywhere>

I'd start by looking here first. This site helped me, when I
was whipping together an MSDOS floppy.

It says "rename" is for files, and "move" is for directories,
whatever that means.

http://www.vfrazee.com/ms-dos/6.22/help/rename.htm

If that isn't it, I'd check to make sure the attempt to "rename",
isn't picking up a script or executable of the same name, from
somewhere in your execution path. Sometimes, when writing scripts,
you give absolute paths for the tools, to prevent surprises. Or,
you define the execution path, local to the script, so the script
doesn't "escape into the woods" :-) Perhaps a built-in command has
priority over a path search, but I don't know enough about your
environment to say what might be the case. I'd just experiment
until I got the right results.

Paul
 
Reply With Quote
 
Todd
Guest
Posts: n/a
 
      17th Oct 2011
On 10/16/2011 09:49 PM, Paul wrote:
> Todd wrote:
>
>>
>> The expanded script look like
>>
>> rename d:\MyBackup\backup1 d:\MyBackups\backup2
>>
>> I am renaming to the same drive
>>
>> I am renaming directories, not files. The directories are full
>> of stuff. Takes about 20 minutes to rename. Bummer.

>
> I'd start by looking here first. This site helped me, when I
> was whipping together an MSDOS floppy.
>
> It says "rename" is for files, and "move" is for directories,
> whatever that means.
>
> http://www.vfrazee.com/ms-dos/6.22/help/rename.htm
>
> If that isn't it, I'd check to make sure the attempt to "rename",
> isn't picking up a script or executable of the same name, from
> somewhere in your execution path. Sometimes, when writing scripts,
> you give absolute paths for the tools, to prevent surprises. Or,
> you define the execution path, local to the script, so the script
> doesn't "escape into the woods" :-) Perhaps a built-in command has
> priority over a path search, but I don't know enough about your
> environment to say what might be the case. I'd just experiment
> until I got the right results.
>
> Paul


I think maybe I am barking up the wrong tree. I have an

attrib -h -s -r %BkPath%
attrib -h -s -r %BkPath%\*.* /S /D

That may be causing the long delays. I will have to check.

Thank you for the help!
-T
 
Reply With Quote
 
Todd
Guest
Posts: n/a
 
      17th Oct 2011
On 10/16/2011 09:49 PM, Paul wrote:
> Todd wrote:
>
>>
>> The expanded script look like
>>
>> rename d:\MyBackup\backup1 d:\MyBackups\backup2
>>
>> I am renaming to the same drive
>>
>> I am renaming directories, not files. The directories are full
>> of stuff. Takes about 20 minutes to rename. Bummer.

>
> I'd start by looking here first. This site helped me, when I
> was whipping together an MSDOS floppy.
>
> It says "rename" is for files, and "move" is for directories,
> whatever that means.
>
> http://www.vfrazee.com/ms-dos/6.22/help/rename.htm
>
> If that isn't it, I'd check to make sure the attempt to "rename",
> isn't picking up a script or executable of the same name, from
> somewhere in your execution path. Sometimes, when writing scripts,
> you give absolute paths for the tools, to prevent surprises. Or,
> you define the execution path, local to the script, so the script
> doesn't "escape into the woods" :-) Perhaps a built-in command has
> priority over a path search, but I don't know enough about your
> environment to say what might be the case. I'd just experiment
> until I got the right results.
>
> Paul


I think maybe I am barking up the wrong tree. I have an

attrib -h -s -r %BkPath%
attrib -h -s -r %BkPath%\*.* /S /D

That may be causing the long delays. I will have to check.

Thank you for the help!
-T
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:50 AM.