I just filmed a wedding, using two different cameras, and realized after the wedding that I corrected only one camera for daylight savings time. My editing software automatically (albeit roughly) arranges the video clips on the timeline based on the time stamps in the file's properties. It would save an incredible amount of time if I could add one hour (plus/minus a couple minutes or seconds, the time synchronization was apparently not perfect) to all of the files in a given folder.
I've found some freeware online that allows me to change all of the files simultaneously, so it resets every file to have the same creation time, rather than just add some preset time to each file. I am not very apt to use or run code, so please keep that in mind when providing ideas! Any and all are greatly appreciated!
Thanks in advance!
You can use a powershell one-liner to do what you need I think.
Open a cmd console and cd into the directory containing the clips you want to modify. Then to add an hour to every file's timestamp you'd just
powershell "gci | %{ $_.LastWriteTime = $_.LastWriteTime.addHours(1) }"
You can do the same thing with .addMinutes as well if you wish. If you want to manipulate the last modified time of an individual file, instead of using Get-ChildItem | foreach (or gci | % as I have it shortened), do
powershell "$f = gi filename.ext; $f.LastWriteTime = $f.LastWriteTime.addHours(1)"
If you mess up and need to subtract hours, do .addHours(-1).
If you have questions, please bear in mind that this is a programming website. If you are uncomfortable navigating the windows file system through a cmd window or need other basic assistance, then SuperUser would probably be a more appropriate place to ask.
Related
I'm writing a batch file to perform recurring operations with choice menu options etc...
but I got stuck on two points.
I tried to read up, but I don't know exactly how to ask questions using search engines.
I try to explain myself.
Problem 1
I need to copy files to a known location, I'd like the batch to stop at some point
and asked me the default source is D:, do you want to copy from here or elsewhere? if so, insert new path
Problem 2
I'm working on Windows .wim images, the command below, as you know, is used to export a single index of these images.
When this command is executed I would like it to stop and ask me if that 4 can go well, or if not
gave me the opportunity to enter another value.
dism /Export-Image /SourceImageFile:d:\Sources\install.wim /SourceIndex:4 /DestinationImageFile:C:\test\install.wim /Compress:Max /CheckIntegrity
At the moment I have not solved the problem.
I am a real novice compared to people on here but I am able to navigate the command line and perform basic actions like move, copy, delete files and folders using the relevant commands. I am aware of the ability to use batch files and I was wondering if anyone coyld help me solve a problem at work. I dont work in IT by the way but I just know there has got to be an easy solution to this from the experience I do have.
Without going into the specifics too much my question comes down to this. I need to move one file at a time(basically a split pdf) from one folder to another at the rate of one per hour. So there may be up to 20 files all in one folder then one gets moved one hour, another the next and so on.
Any help would be greatly appreciated. :)
What you're looking for is probably a cron. Cron's function is to run a certain command on a certain interval. To move a file once per hour you would use a crontab which is a file that specifies what to run and how often to run it. your cronfile might look somthing like this 0 * * * * <your move command>. The to execute the cron you'd do somthing like contab /path/to/your/crontab/file
In my HTML page, I am showing c*urrent day and last 4 days reports*. I have already designed HTML page. But for every day, I have hard-coded the JPG Image filename.
I am using naming convention as follows -
For Current Day, CurDt_S1
For Current Day minus 1 day, CurDt_1_S1
For Current Day minus 2 days, CurDt_2_S1
For Current Day minus 3 days, CurDt_3_S1
For Current Day minus 4 days, CurDt_4_S1
Now, I want to rename a series of .jpg but i want to append the string at the end of file name. Please help me how can I achive this. Through vbscript or HTML or batch file.
I tried using batch file but it is not working for me.
Series of jpg files - CurDt_S1, CurDt_S2, CurDt_S3 etc.. uptill S20.
CurDt_S1 will be renamed as CurDt_1_S1 uptill S20
CurDt_1_S1 to CurDt_2_S1 uptill S20
CurDt_2_S1 to CurDt_3_S1 uptill S20
CurDt_3_S1 to CurDt_4_S1 uptill S20
CurDt_4_S1 files will be archived to a diff folder or would be deleted
Any SIMPLE solution which i can code is welcome. :)
Thanks.
First off, HTML won't be able to offer anything for this. It is a markup language, not a programming language.
In visual basic, you have a lot of options though. Firstly, you want to be changing the filename, which you can do using
My.Computer.FileSystem.RenameFile(fileX, fileY)
In the case of Cur_Dt_4_s1 you would be using
My.Computer.FileSystem.MoveFile("C:\directory1\file.txt","C:\directory2\file.txt")
To handle the name changes, first create a loop which will run through the folder of these jpegs.
Next, load each file in order, using a method from the path class to get collect the entire path for each file as a string. As you have maintained a standard naming system for your files, all it takes is:
result = Path.GetFileName(fileName); //result being a string
and then, because the string "result" is already an array of chars access the 6th character (your number) by using:
Dim charNum = result(5)
To change 'charNum' to an integer, use
CInt(charNum)
After that it's pretty simple. You'll +1 the variable you made from CInt-ing the number, then converting it back to a character with CChar, pushing it back in to the array in the same position, and then using that new string as the variable you will have for the fileY string.
Hopefully you can explore this a little better yourself, but I will construct the code properly if you are still struggling.
I finally figured out the SIMPLEST way to achieve this bu using BATCH FILE in simplest way.
By Using following code -
del CurDt_5_S*
ren CurDt_4_S* CurDt_5_S*
ren CurDt_3_S* CurDt_4_S*
ren CurDt_2_S* CurDt_3_S*
ren CurDt_1_S* CurDt_2_S*
I tested it and its working. :) :) :)
In c#, given a folder path, is there a way to get the last modified file without getting all files?
I need to quickly find folders that have been updated after a certain time and if the file that was last modified is before the time, i want to skip the folder entirely.
I noticed that folder's last modified time does not get updated when one of its file get updated so this approach does't work.
No, this is why windows comes with indexing to speed up searching. The NTFS file system wasn't designed with fast searching in mind.
In any case you can monitor file changes which is not difficult to do. If it is possible to allow your program to run in the background and monitor changes then this would work. If you needed past history you could do an initial scan only once and then build up your hierarchy from their. As long as your program is always being ran then it should have a current snapshot and not have to do the slow scan.
You can also use the Window Search itself to find the files. If indexing is available then it's probably as fast as you'll get.
Try this.
DirectoryInfo di = new DirectoryInfo("strPath");
DateTime dt = di.LastWriteTime;
Then you should use
Directory.EnumerateFiles(strPath, "*.*", SearchOption.TopDirectoryOnly);
Then loop the above collection and get FileInfo() for each file.
I don't see a way how can you get the modified date of a file w/o getting reference to FileInfo() on that file.
I don't think FileInfo will get this file as far as I know.
I work extensively using the shell. When I continue working on some project one week later, I go to some "folder" and realize that I do not remember what I was doing. Sometimes and before stopping work what I do is:
history > DIRX_HISTORY_20100922
so later I have a look at the commands I used, I can remember much better what I was doing.
I wonder if somehow, some script or something could do this automatically each time I type a command in a directory, so this DIRX_HISTORY_20100922 is created and a new one is modified depending on the date and on the directory name.
Thanks
Have a look at my history logging functions. They save the current directory along with the command that was executed. You can grep for the directory and it will show you the commands that you were using there.
Bash's PROMPT_COMMAND variable can be used to save the last line of your history to a file for every command you enter.
ie.
PROMPT_COMMAND="history 1 >> DIRX_HISTORY"