by netsharc · 1mo ago · 0 comments
So if you have ffmpeg.exe in C:\Program Files\FFMpeg\bin, and you have some source files in D:\SourceVideos, and you want to process them in ffmpeg and output them to E:\Output you can do:
C: (to navigate to the C: drive)
cd "C:\Program Files\FFMpeg\bin"
E: (to navigate to the E:\ drive)
cd D:\SourceVideos (you remain in E:\, but the "current directory" for D: has been changed).
cd Output (to enter E:\Output)
You can now do C:ffmpeg.exe -i D:scene1.mp4 output-scene1.mp4
and Windows accesses the files in the "current" directory on each drive letter.
(Really, people don't engage more with physical machines to consider programming. We insist that everything has to be distilled down to symbolic functions. Preferably limited inputs and a single output. If only life was so accommodating.)
`CD` without any arguments will display the current directory on the current drive.
`CD E:` will display the current directory on the `E:` drive.
No state chnages for either case.
And you think adding to it will improve things?
But a lot of times, you also need to think about executing programs from within a script, where you don't have this prompt. Thus, it's invisible state.
Why is it horrible? It's just basic and well-documented system behavior.
Then there's Path Canonicalization. This is especially hairy, and only needed in certain circumstances where you need to know when two paths are really on the same filesystem or not (Mount points and symbolic links can cause "C:\dir\file" to be on a different drive than "C:\"). Not helping this is that path canonicalization is broken on Windows in some cases. When you mount a filesystem, you are able to register the volume with the mount manager. If you do register it, path canonicalization will work, but you also get some unwanted side effects (creating a "Recycle Bin" and "System Volume Information" directory). If you don't register it with mount manager, the files are still usable, but Path Canonicalization won't find the drive. You have to enumerate every drive letter to find it, and if you mounted it inside a directory, that's even harder.
(navigate to one directory)
src=$PWD
(navigate to another directory)
dst=$PWD
(navigate wherever you like)
You can now do: ffmpeg -i "$src/scene1.mp4" "$dst/output-scene.mp4"
If you avoid spaces and other special characters in directory and file names, then you can skip the quotes.
This is conveniently not limited to a system wide partitioning scheme.
It allow you to pretend a directory is a drive, and thus gives you multiple current directories on a drive.
This won't actually work because multiple current directories are a fiction of cmd.exe
https://www.kylheku.com/cygnal/
It's behind quite a bit; haven't done a rebase in a while.
This is just one of the features (Issue 7); the idea is to provide a POSIX run-time for easily porting programs to Windows, but follow the conventions of the Windows environment.
I remember that NT4 did not have "current directory" context for each process. But but apparently[1] windows 2000 had it already. So what you write above is per process and not per logged in user right?
Asking, because I remember that Citrix which did Terminal Server 4.0 for NT4 had to license windows source code to be enable to make changes for their product at least somehow working with NT4. Up till that time Winddows did not keep current directory per process or at least user, but it was a global state.
So if you changed with "cd" current directory it changed for all processes which was a big issue for Citrox as they did look a way to make Windows a server class system, where each user had distinct environments with distinct default directories etc.
For me as I heard that then I did not understand what was Microsoft thinking letting still with NT such misfeatures remain shipped product and especially when they had real talent Dave Cutler been working on it.
I haven't been using windows besides using Visio a separate local VM since turn of century. So is Windows been since 2000 etc. a real multitasking multiuser system or does it still suffer such handicaps it had at least before?
[1] Microsoft licensed Citrix made changes and RDP protocol they had developed, then brought Server 2000 with terminal server product to compete with Citrix Terminal Server.
What a footgun.
If you want to actually change the working directory and drive at the same time (which is the "absolute path" idea you have), you do `cd /d D:\whatever\`.
At least if I had to write one, I saw cd is available and seemingly working as expected, and wrote a cd to an arbitrary target I would not expect it to behave that way at all - my expectation would be that either the next command always runs in the cd'd path, or at least that cd errors on a path in a different drive.
It was common practice when writing RISC OS programs (and recommended by Acorn) to store your application's directory path into a system variable, and then use that to refer to all the ancillary files you needed.
Whether or not the gun fires comes down to what you're most accustomed to