How to move multiple files when moving only one file - windows

If you've ever saved a a full webpage you'll notice that it creates the .htm file and a folder that contains all the icons and scripts for the page.
If you move the .htm file to a new location, the folder that came with it moves to the same location, and the behavior is the same if you move the folder, the .htm file will move with it.
How can I do that with any old file/folder combination? Can this be manipulated?
EDIT: Programmatically (through CMD)
Is there a command that binds files to other files etc.?

This is a feature of the shell called Connected Files. It is specifically implemented for web pages; it is not generic or extensible as far as I know.
It doesn't even seem that useful to me as it only works when using the shell mechanisms (SHFileOperation and friends); if plain old CopyFile/MoveFile are used then all the files need to be handled individually.

Related

Reason why folder associated with saved webpage gets deleted when we delete saved page

I have saved a complete webpage and there is also one folder saved with resources but when I delete webpage or move saved webpage to other directory then the folder associated with it also gets deleted or moved. So what is the code written behind it. Because I want to do same with my webpage and folder.
Thanks in advance for you kind help.
This "association" between the HTML file and its resources folder is a behaviour implemented by the Windows operating system.
It has nothing to due with a webpage in particular, with its HTML, JavaScript, or even with a particular browser.
Windows 2000 provides a simple way to connect a primary HTML file to its group of associated files. If Connected Files is enabled, when you perform any of the commands [Copy, Cut, Paste, Move, Delete, Send To] on a file or folder of associated files, the same command is performed on all connected files.
Even though the official page mentions "Windows 2000", the same behaviour is implemented in Windows XP and many (if not all) later versions of Windows.
See these pages:
Removing file / folder link after using “Save As…” then “Web Page, complete”
Operations on an HTML file or folder apply to similarly named folder or HTML file (from Microsoft support)

Changing default program for a file type (workaround)

I would like to specify that images of a certain type (for example, .png) open by default in a program I've written when the file is contained in a certain directory. I've seen by searching (Change Default Program for a specific folder) that this is not possible on Windows 7 or 8.
I am saving these images in this directory myself, so I have some leeway with how I name the files. For example, I could change the filename a bit... perhaps to be example.myprog.png or something similar. Is there a way to set it up so files that match this filename pattern get opened, while other .pngs (in other directories) still open in the default viewer?
I don't really want to name these PNG images example.myprog (i.e., fully change the extension), because when the user is browsing the directory in Windows Explorer, I would like the thumbnail images to still show up. Also, users will be eventually transferring these images to their own machines, where they'll want to use standard image viewers to look at them.
If this is not possible, does anyone have another suggestion for how to tackle this problem?
As you are mentioning that files should be opened in a program that you have written, try to change the code of your program to read files from the specific folder. So, by opening your program from anywhere in your pc, you should be able to open files from specified folder.

"Virtual Files" in OSX Finder that only appear when my Application runs, possible?

is there a way to "hook" into the OSX Finder to perform the following:
When my Application starts, the User sees a Folder in his Finder which is created by my application. Inside this Folder the User sees Files from several Folders...a unified view to several Files in several Folders that the User specified in my Application.
So, in this "Unified Folder" are not the real Files, they are still in there original Folder but the User sees them in this one Folder as if there were all his real Files in this new Folder. So there is no copying or moving involved.
To be honest, I've no Idea if it's possible and what I should looking for inside the Cocoa SDK. Maybe there is an API for the Finder itself or some other way?!
Regards
twickl
First option is your application could create aliases to the original files. The Finder will show these with a small arrow "badge" over the icon, so it is clear they are not the original files but aliases of them.
If you don't like the badges on the icons creating hard links may give you what you want.
Mac OS X presents a view of the HFS+ (Mac) filesystem which matches the UFS (Unix) one and you have access to hard and symbolic links. The latter are treated by the Finder similar to aliases but the former are indistinguishable from the original files as they are the original files - under the Unix filesystem a file in a directory is just a reference (the inode number) to the real file, each entry in a directory is just a hard link to the actual file, and a file can have any number of hard links to it (a file is deleted when the link count drops to 0, think of the retain/release model if that helps).
At the Cocoa level NSFileManager has methods to create hard links, or you can use the Unix level link(2) function.

How can I determine which folder the user was browsing when my program was invoked from the "sent to" menu?

I put a shortcut to my application in SendTo. Now I can select some files in Explorer and send them to my application. But how can I get the path where the files are? My program is supposed to create a new file in the parent directory that's common to all the received file names.
For example, if I have these files:
C:\one.txt
C:\1\
I select the file one.txt and the directory 1 in Explorer. How can I find out that the starting directory for these files is C:\?
I know I can use ParamStr() to get files' paths, but what then?
I could try to get common directory for all the files passed to my application, but if I select in C:\ directories 1 and 2 and these directories look like this:
C:\1\4\5\one.txt
C:\1\4\two.txt
Then the starting directory is C:\1\4.
Prior to Windows 7, all files selected in Explorer always reside in the same directory, so it's easy to know which directory the user was browsing. It's the same as the directory of any one file. Use ExtractFilePath for that.
As of Windows 7, though, Explorer lets you put directories into groups called libraries. All the files from all the folders are displayed together in a single view. Users can select files from multiple directories and send them all to your program at once. The view doesn't represent any real directory on the disk, so the question asked here is meaningless.
As an alternative, you could decide use the ancestor directory common to all the files sent to your program, but that won't tell you much. For one thing, if the files reside on multiple drives, the common directory will be the empty string. The directory you calculate also might not be writable by the current account, even if the directories of one or more of the selected files are.
It will probably be easier to just use the directory of the first file you receive, or even to display a UI that asks the user what directory to use in the cases you can't determine it automatically. (Maybe you could pre-populate the result with the first directory, so the user doesn't have to do anything but approve your suggestion in the common case.)
I think I will just take all the filenames passed to my program via ParamStr and use this function:
http://delphi.about.com/od/delphichallengesexercises/qt/delphi-extract-base-path-challenge.htm
to find common base path which should be the path where the SendTo was invoked.

Does Windows cache the contents of .url (Internet Shortcut) files?

I'm implementing a custom URL handler in .NET. To test this, I have created a few different .url files and put them on my Desktop. This generally works fine, but behaves oddly if I change the file's contents, specifically the URL= line. Doing so has no effect — the old URL continues to be opened. Renaming the file, however, works. The file looks like this:
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,0
[InternetShortcut]
URL=myCustomScheme://some/url/pointing/somewhere
IDList=
All shortcuts I create through New → Shortcut receive the same UUID, so changing that probably won't help.
Is there some internal .url file / URL mapping cache in Windows?
I have a reason to believe that URL files are interpreted by some Internet Explorer component at the time of creation (not biblical). They are only interpreted initially, the first time the file is created. Any modifications to the URL file later on will not be committed. This is because the shortcut is not stored in the file. This is why the file can be modified later on so that it becomes empty, as a 0 byte file and the URL file will appear to be working anyway. The shortcut data is stored in the "Web Document" field as a file property in the NTFS file system. The file merely serves the purpose of pointing to it. You might be able to modify these property fields programmatically, which would supposedly "edit the file". It's a painful exercise just to edit what appears to be a simple text file.
Additionally, once a file name has been used for a URL file, it cannot be reused for new files, no matter what disk or path you save it to. So you have to keep assigning unique file names, never used previously, for each new URL file you create. This has to do with how Internet Explorer caches web content. It remembers what file names have been used already and maps those names to previously defined URL addresses. To reuse a name (or when you run out of ideas for new and unique file names) you have to clear Temporary Internet Files.
Windows 7: %localappdata%\Microsoft\Windows\Temporary Internet Files
Windows 8: %localappdata%\Microsoft\Windows\INetCache
To directly answer your question: yes, it does.
Windows 7 Caches your Filenames and sometimes, as you said, the filenames in specific locations.
Start regedit and search for the following
HKEY_USERS\S-1-5-21-x-x-x-x\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache
where S-1-5-21-x-x-x-x is your currently logged in User.
There you can see that most (or all?) files have been cached which you have ever accessed.
Maybe you can also deactivate the MUICaching programatically. Maybe this site helps you: Disable Caching
I had a similar issue, and it turns out the culprit was Firefox.
If by chance your web browser is Firefox, your cache directories may be corrupted.
You can either create a new Profile, or take your chances cleaning things out of C:\Users\<username>\AppData\Local\Mozilla\Firefox\Profiles\<profile>\
I've found my desktop .url shortcut contents cached in %LocalAppData%\Microsoft\Windows\Caches.
There are a few (several?) files with filenames like {<SOME_GUID>}.<x>.ver0x<XXXXXXXXXXXXXXXX>.db. Two of them had the .url files cached.
Unfortunately, I've found no information on what they are or how to refresh them. Everybody just deletes them as part of some cache clean-up operation.

Resources