Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

How Do I Make a Folder 'Follow' a File When Copied/Moved?


  • Please log in to reply
6 replies to this topic
Rhys
  • Members
  • 761 posts
  • Last active: Aug 09 2013 04:53 PM
  • Joined: 17 Apr 2007
When I create a webpage using a MS Word, if there are any embedded images, they are saved in a [document_name]_files folder that word creates when saving as html. Whenever the .html file is moved, the _files folder follows it... Also, if I try to rename the .html, Windows warns me that the file will no longer belong to the _files folder.

This behavior is kind of neat and I'd like to replicate it (manually, outside of Word), but I'm not sure what to search for since I don't really know the terminology involved in this.

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
ShellFileOperation() does it by default unless you specify FOF_NO_CONNECTED_ELEMENTS in flags.

:)

Rhys
  • Members
  • 761 posts
  • Last active: Aug 09 2013 04:53 PM
  • Joined: 17 Apr 2007
I'm not sure we're talking about the same thing... Here's what my folder would look like if I save a document called 'helpdocument' as HTML via Word:
Index of My Documents:
helpdocument_files (folder)
helpdocument.htm
If I move or copy helpdocument.htm somewhere else, the folder that's assigned to it 'follows' it to the new location, automatically...

Mustang
  • Members
  • 421 posts
  • Last active: Dec 26 2010 10:08 PM
  • Joined: 17 May 2007
Easiest way would be to have a custom hotkeys
That copies (ctrl+alt+s maybe)
Or renames (maybe alt+f2)
etc.

Then for each hotkey after making the copy or rename it does a "SplitPath" to get the "OutFileName"
Then a concat with "_files"
Followed by an "IfExist" for the folder name
And then the relevant opperation e.g. copy or rename the folder as well

The more complicated method (shouldn't be much harder but Id get the other way working first)
Would be to interupt or hook all the events that could cause a copy or rename of the file
Then perform the same as above

At least this would be my approach

Edit:
Is this not an "Ask for Help" topic?
Or did you wish for a solution that doesn't involve using AHK?

Rhys
  • Members
  • 761 posts
  • Last active: Aug 09 2013 04:53 PM
  • Joined: 17 Apr 2007
Well the original behavior happens completely outside of AHK so there's got to be a way to make it happen using just Windows. I just have no idea what this behavior is even called or where to find out more about it.
When I try to rename the main .htm file, Windows warns me that if I do this, it will no longer be owned by filename_files folder (or maybe vice versa). I kept it out of Ask for Help since it's not really AHK-related.

Edit: lol, I just found this topic in Google, searching for answers. I also found a Microsoft Support page about it: <!-- m -->http://support.microsoft.com/kb/252721<!-- m --> It looks like the feature is called 'Connected Files' so that will give me somewhere else to look.
Edit2: I guess it's automatic... If you create filename.htm(l) and a folder called filename_files (or many other extensions listed at the above link) it will just happen.
Edit3: Here's another good page about it <!-- m -->http://xona.com/2004/07/16.html<!-- m -->
Looks like Skan was right, I just didn't understand what he meant! :oops:

engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
I seem to remember that there was an option in TweakUI that could enable/disable this feature. It's enabled by default.

ahklerner
  • Members
  • 1386 posts
  • Last active: Oct 08 2014 10:29 AM
  • Joined: 26 Jun 2006
From SKAN's Linked link (MSDN Page)

Connecting Files

With Microsoft Windows 2000 or later, it is possible to connect an HTML file with a folder that contains related files such as Graphics Interchange Format (GIF) images or style sheets. If file connection is enabled, when you move or copy the HTML file, the connected folder and all of its files are also moved or copied. Conversely, if you move the folder with the related files, the HTML file is also moved.

The HTML file must have a .htm or .html extension. You create the connection to the related files by placing the folder that contains them into the same folder as the HTML file. The name of the folder that contains the connected files must be the same as the name of the HTML file followed by "_files" or ".files" (this is case sensitive; for example, ".Files" does not work). An example is given here.

1. Create a file named Test.htm in the C:\Files directory (C:\Files\Test.htm).
2. Create a new folder named Test.files in the C:\Files directory (C:\Files\Test.files).
3. Populate the folder with a few files. Any file placed in this folder is connected to Test.htm.
4. Move or copy the Test.htm file to the C:\Files2 directory.
5. Note that the Test.files directory is now found in the C:\Files2 directory as well.


Posted Image
ʞɔпɟ əɥʇ ʇɐɥʍ