topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Tuesday October 15, 2024, 11:26 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA: Create folder structure or path  (Read 25469 times)

IrmaIsfot

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 9
    • View Profile
    • Donate to Member
IDEA: Create folder structure or path
« on: April 22, 2009, 05:24 AM »
I would like to be able to create a 'copy' of a path. 

For example, let's say I have a file in this folder:
C:\Documents and Settings\All Users\Documents\My Pictures\

I would like to copy this file to D:\temp so that the path becomes like this:
D:\temp\Documents and Settings\All Users\Documents\My Pictures\

Now, I would have to go to D:\temp, create the first folder Documents and Settings, then enter that folder to create the next All Users folder, and so on, before I can copy my file to that location.

If possible, I'd like a right click option in Windows Explorer to select 'Copy with path' and then 'Paste and create path'.

I hope I have managed to explain myself?

Thanks!

/Håkan, Sweden

IainB

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 7,543
  • @Slartibartfarst
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: IDEA: Create folder structure or path
« Reply #1 on: April 22, 2009, 05:15 PM »
It might help if I describe what I would do and/or actually do.
To do what you are suggesting - i.e., Create folder structure or path - I think I would first use xplorer2 (a brilliant product  :Thmbsup: ) to create a duplicate copy of just the directory structure. I have not needed to do this myself, but page 183 of the xplorer2 User Manual (Version 1.7.2.0-1) describes a 3-step approach to doing this:

Copying only the structure of a directory
This powerful command copies an entire directory structure into another
place, minus its contents. All the subfolders of the original directory are
copied recursively, but files in them are not copied.
The original directory is not affected by this command at all. To copy
structure, follow these three steps:

1. Select the top-level folder and press CTRL+C (or select the Edit |
Copy menu option)

2. Go to your destination folder (the folder where you want to place the
copied structure).

3. R-click and from the context menu that pops up, select the Paste
special | Folder structure menu option. (Instead of the context menu,
you can also use the Edit |Paste special | Folder structure menu
option.)


Once I had the duplicate structure set up, I would use the sync and mirror copy functions in xplorer2 to copy files individually or in blocks, from the original structure to the duplicate structure. I sometimes use this approach when manually updating/checking some of my duplicate files/directories on different devices- e.g., backup drives, or USB memory sticks that I use for portable applications.

The manual goes on to describe some circumstances under which you might find duplicating a directory structure useful:
It also describes the two ways to do it in Windows Explorer (one of which you described), and describes the corresponding disadvantages:

We never did this before because doing it with Windows Explorer had some
serious problems. With Windows Explorer, you can follow two different
optional methods to copy structure; and both have problems, as we will see:

> Copy the entire top-level folder to a new place (along with its
subfolders and their contents). Now find all files in this directory by
launching a search with *.* as your search condition. Explorer will
list all files in the directory. Select all of them and delete. This will
leave an empty folder structure that is identical to the original folder
system.

The disadvantage in this method is that you need a huge free disk
space at the destination drive, because the entire contents of the
original directory have to be accommodated there before you start
deleting them.

> Creating each subfolder manually. This is an extremely laborious
method if you have to create large directory structures. You may
make numerous mistakes, which requires enormous correction effort.
Besides, if you don’t realize your mistake, you will actually create a
different subfolder!


You can get a free Lite version, or buy a trial Pro version of xprorer2 from here: http://zabkat.com/

Hope this helps or is of use.  :)

IrmaIsfot

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 9
    • View Profile
    • Donate to Member
Re: IDEA: Create folder structure or path
« Reply #2 on: April 27, 2009, 03:28 PM »
Thanks for the suggestion!

This, however, is not what I want to achieve.  I found this free sw to do what I think you suggest to do with xplorer2: TreeCopy

But both of these two programs will create a whole tree of branches, when I only want one single branch!

If I want the branch \Documents and Settings\All Users\Documents\My Pictures\ (like in my first post) I would have to copy the 'Documents and Settings' level.  That would give me a copy that looks something like this:

D:
 | temp
     | Documents and Settings
         |  Administrator
              |  Everything below here
         |  All Users
              |  Application Data             
                  |  Everything below here
              |  Desktop
                  |  Everything below here
              |  Documents
                  |  My Pictures
              |  Favorites
                  |  Everything below here
              |  Start Menu
                  |  Everything below here
         |  Default User
              |  Everything below here
         |  User1
              |  Everything below here
         |  User2
              |  Everything below here

When all I really want is this:
D:
 | temp
     | Documents and Settings
         |  All Users
              |  Documents
                  |  My Pictures


Sure, I could use this method to create the complete empty structure, then copy my file to the desired destination, and finally use the convenient little DelEmpty-app by Skrommel.  But that's kind of an uggly solution...

So, suggestions please..?  :huh:  Is there maybe an easy way to do this already?

Otherwise, I'm thinking a program that adds options to the context menu in Windows Explorer.  When right-clicking a folder, the context menu would offer "Copy folder path" (implies from root to here), and when right clicking another folder, the menu would offer "Paste folder path" if one is present in the clipboard. 
If you do not want the complete path from the root, you could manually copy just a selection of it from the Address-bar, which places it in the clipboard, and thus makes it possible to paste with "Paste folder path".

Now, that'd be great!  :D

/Håkan


MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA: Create folder structure or path
« Reply #3 on: April 27, 2009, 06:03 PM »
Does this look like what you mean?
http://www.codeproje.../Folder_Utility.aspx

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA: Create folder structure or path
« Reply #4 on: April 27, 2009, 07:10 PM »
AHK has a function to make the folder chain, so that part is easy.

This script provides an input box.  If you type (or paste)an absolute path such as c:\temp\temp\mytemp it will create the folder if it doesn't exist. If you type a path say test\test\mytest   it will start the chain in the working directory(where the script is located.) At the end it opens the folder so you can at least drag & drop the file(s) into it.  Guess I'm a bit lazy :)

;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         MilesAhead
;
; Script Function:
; Creates new folder chain and opens terminal folder
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#NoTrayIcon
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
InputBox,DirName,CreateDir,Enter New Folder to Create
If ErrorLevel
Exit
IfNotExist,%DirName%
FileCreateDir,%DirName%
run explorer %DirName%

IainB

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 7,543
  • @Slartibartfarst
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: IDEA: Create folder structure or path
« Reply #5 on: April 27, 2009, 07:28 PM »
@MilesAhead: That Code Project bit was spot-on.  :Thmbsup:
I was just wondering how to put that code into an AHK script (I am a beginner in AHK) when your post with the script popped up. Thanks! Nice work and smart thinking, Batman - if you don't mind my saying so! (...and at the risk of further inflating your possibly already over-inflated ego).   ;D

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA: Create folder structure or path
« Reply #6 on: April 27, 2009, 07:42 PM »
Overinflated?  I was just thinking my humility has been holding me back all these years!! heh heh

Thank you.  I'm glad the OP posted the question because I'm new to ahk too and I didn't know that function was there.  Now I also have another handy small util.

I compiled it and zipped it up with a readme:

http://www.favessoft.com/hotkeys.html

Just scroll to the bottom of the page to download.


MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA: Create folder structure or path
« Reply #7 on: April 28, 2009, 11:20 AM »
I changed the program so that it doesn't use the script path as the working directory and added a command line param. The "working directory" is now the current directory of the command prompt, or the Start In value if run from a shortcut.  For relative paths if you type
CreateDir test\test
and the command prompt is in c:\temp
the result should be
c:\temp\test\test

it still pops up an InputBox with the command line already entered so that you can confirm that's the folder you want to create, or cancel.

It's available for download now.


« Last Edit: April 28, 2009, 11:22 AM by MilesAhead »

Target

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,832
    • View Profile
    • Donate to Member
Re: IDEA: Create folder structure or path
« Reply #8 on: April 28, 2009, 06:00 PM »
here's another try -

#singleinstance
#persistent
outpath:="::{20d04fe0-3aea-1069-a2d8-08002b30309d}"
return

$F11::
fileselectfolder, OUTPATH,*%OUTPATH%,3
Path_tmp:= outpath

loop, parse, clipboard,`n,`r
{
filegetattrib, myATTRIB, %A_loopfield%
ifnotinstring, myATTRIB, D
{
Stringgetpos,myPOS,a_loopfield,\,R
stringleft, mySTRING, a_loopfield, %MyPos%
}
else
MySTRING:=a_loopfield

if substr(mySTRING,2,1) = "`:"
stringtrimleft,mySTRING, mySTRING,3

loop, parse, mySTRING,\
{
filecreatedir,%path_tmp%\%a_loopfield%
Path_tmp.= "\" . a_loopfield
}
mySTRING:=
MyPOS:=0
PATH_tmp:=outpath
}
return


runs all the time, copy a folder (CTRL+C) and use the hotkey (F11) to duplicate the folder and it's associated path in the folder of your choice (you get a prompt to select the target dir when you use the hotkey

also works with files (the file name is stripped out of the path), and with multiple folder selections, ie selecting

C:\
   | Documents and Settings:
       |  Administrator
            |  All Users
            |  Application Data             
            |  Desktop
            |  Documents
            |  My Pictures
            |  Favorites
            |  Start Menu
       |  Default User
       |  User1
       |  User2

You'll end up with

D:
 | temp
     | Documents and Settings
         |  All Users
           |  Desktop
           |  Documents
           |  Favorites
 
the tray icon could also be removed to reduce the clutter

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,776
    • View Profile
    • Donate to Member
Re: IDEA: Create folder structure or path
« Reply #9 on: April 28, 2009, 07:06 PM »
Works perfectly here  >:(

Target

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,832
    • View Profile
    • Donate to Member
Re: IDEA: Create folder structure or path
« Reply #10 on: April 28, 2009, 07:43 PM »
sorry to disappoint :-[

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA: Create folder structure or path
« Reply #11 on: April 29, 2009, 03:13 PM »
ChainCopy Beta    :Thmbsup:

edit: by the way if anyone notices any bugs feel free to post or you can email to the address shown in the Readme.txt file included with the download.
« Last Edit: April 29, 2009, 07:54 PM by MilesAhead »

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA: Create folder structure or path
« Reply #12 on: April 30, 2009, 03:01 PM »
Note that I updated CreateDir  command line handling.
/q switch quiet mode for scripts and batch files
/? switch shows a Help Dialog

ex quiet mode usage creates folders without prompting

CreateDir /q  dir\sub1  dir\sub2 c:\somedir\subdir2


fhayes

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 19
    • View Profile
    • Donate to Member
Re: IDEA: Create folder structure or path
« Reply #13 on: May 06, 2009, 06:42 PM »
I've been using this nifty free tool from RJLSoftware to do exactly what you're asking. It's called "TreeCopy"   
From the authors site:

Have you ever needed to copy a directory structure without copying the files? TreeCopy now makes this possible. Our small program will allow you to select the "from directory" and "into directory", and it will proceed to copy ONLY the directory structure. The utility is bundled with functionality such as a command line interface, calculate directories, Windows XP look and feel and much, much more!TreeCopy is a free download, so try it out.

oops, sorry, I see you've already found this one. Guess I should read the whole thread before posting..
« Last Edit: May 06, 2009, 06:53 PM by fhayes »

DonL

  • Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 171
    • View Profile
    • XYplorer File Manager
    • Donate to Member
Re: IDEA: Create folder structure or path
« Reply #14 on: April 26, 2012, 05:13 AM »
I would like to be able to create a 'copy' of a path. 

For example, let's say I have a file in this folder:
C:\Documents and Settings\All Users\Documents\My Pictures\

I would like to copy this file to D:\temp so that the path becomes like this:
D:\temp\Documents and Settings\All Users\Documents\My Pictures\
Late revival, I know. But it happens to fit so well...

The latest XYplorer 11.00 features this functionality as "Copy Here With Path",  "Move Here With Path",  "Paste Here With Path". See http://www.xyplorer.....00.htm#CopyWithPath

shmuel1

  • Supporting Member
  • Joined in 2012
  • **
  • default avatar
  • Posts: 48
    • View Profile
    • Donate to Member
Re: IDEA: Create folder structure or path
« Reply #15 on: May 21, 2012, 07:20 AM »
If you want to do this for backup or sync purposes, you might want to consider Beyond Compare. It's an excellent sync utility and it will automatically create the path for you.

On the left side, you would select the location to copy from, let's say "C:\Documents and Settings\All Users\Documents\My Pictures\"
On the right side you would select (in your example) D:\temp
Then you would copy "\Documents and Settings\All Users\Documents\My Pictures\" from the left side to the right side to get this:
"D:\temp\Documents and Settings\All Users\Documents\My Pictures\"
Then sync the folders. Beyond Compare gives you the option of automatically creating the directory structure.