LogParser 2.2 Unable to get Filesize - logparser

Currently trying to get the folder sizes So I can compare 2 directories with Long File names.
It was recommended that I should use Log Parser as it will show files longer then 256 Characters. However when I run the command I get a syntax error that I'm Not sure how to fix.
LogParser "SELECT EXTRACT_PREFIX(Path, 1, '\\') AS Folder, SUM(Size) FROM C:\*.* GROUP BY Folder
The error i get is
WARNING: Input format not specified - using TEXTLINE input format.
Error: SELECT clause: Syntax Error: unknown field 'Path'
To see valid fields for the TEXTLINE input format type:
LogParser -h -i:TEXTLINE
Any help would be appreciated! or if you can suggest an alternative way to compare 2 directorys Folder sizes with Long file names that would be great

Figured it out, Needed to add the -i:FS tag to the end
Correct Code is
LogParser "SELECT EXTRACT_PREFIX(Path, 1, '\\') AS Folder, SUM(Size) FROM C:\*.* GROUP BY Folder" -i:FS

Related

How to make sure date/time syntax is correct in batch script

I have a line in a batch file that renames a file with a date and time appended to it.
rename "C:\Program Files (x86)\File Directory\sub directory\logs\Backups\Client.txt" Client%date:~7,2%%date:~4,2%%date:~10,4%%time:~0,2%%time:~3,2%%time:~6,2%.txt
This works fine, except if the first time parameter (%time:~0,2%) is a single digit. It will error with an incorrect syntax command. I understand why it occurs (there's a similar post here) but can't seem to get the correct syntax to make the command run successfully when the hour parameter is a single digit (between 01-09).
What command syntax do I need to add to make sure the command works with single digits for the hour ?
set hour=%time: =0%
rename "C:\Program Files (x86)\File Directory\sub directory\logs\Backups\Client.txt" Client%date:~7,2%%date:~4,2%%date:~10,4%%hour:~0,2%%time:~3,2%%time:~6,2%.txt

Octave 'input' function, run through batch file

I am using a batch file:
#echo off
C:\Octave\Octave-4.4.1\octave.vbs --force-gui --eval batchTest("'%~dp0'")
cmd /c
to run an Octave script
function [] = batchTest(fPath)
disp(fPath);
cd(fPath);
optionNumber = input('Choose option 1 or 2: ');
if optionNumber == 1
fName = input('Input file description: ',"s");
filename = [fName ".xlsx"];
xls = xlsopen(filename,1); % <-- THIS DOES NOT WORK, PRODUCES "FILE POINTER PRESERVED MESSAGE"
xls = oct2xls({"OutputData"},xls,1,"A1");
xlsclose(xls);
end
if optionNumber == 2
filename = "TestFile.xlsx";
xls = xlsopen(filename,1); % <-- THIS WORKS AS EXPECTED
xls = oct2xls({"OutputData"},xls,1,"A1");
xlsclose(xls);
end
to create an Excel file in the batch file's directory.
Option number 1 produces a "File pointer preserved" warning, and the Excel file is not created. It seems that I can't use any string that was created, in whole or in part, by Octave's 'input' function. Inputting the full filename with ".xlsx" and passing that variable to the 'xlsopen' function does not help. Option 2 works fine, but I need to produce multiple files, so the "fName" descriptor is important. I've tried adding SETLOCAL ENABLEDELAYEDEXPANSION to the batch file. I've also tried a work-around where I used Option 2, and then added
rename("TestFile.xlsx",[fName ".xlsx"])
to the Octave script, but this produces an "invalid input" error in the 'rename' function, so it doesn't like the 'input'-created string either. The problem is only with the 'xlsopen' and 'rename' functions; the 'input' function works just fine for choosing the option number.
Either option works when directly executing 'batchTest(pwd)' from the Octave command line. The issue only arises when executing from the batch file. Any advice would be much appreciated.
The issue sounds to be that when you create your string, you are including escaped characters that mess up your filename.
From the discussion in the comments it seems the carriage return character is being included in your string, resulting in a wrong filename.
It is unclear why this is only the case when running from the batch file, but as a workaround, you can ensure that the carriage return is removed by preprocessing your string input with strtrim to remove any unwanted whitespace.

How to set file's DateTimeOriginal from file name using ExifTool

I have a directory with many image files that don't have their DateTimeOriginal metadata set, but do have this date in the file name itself in the format of YYYMMDD, e.g. 20120524_091536.mp4
I want to use exiftool to move these files into folders with the year and then sub-folders of the month (then later also set its DateTimeOriginal using this date from the filename).
Something like this:
exiftool -d "%Y-%m-%d" "-testname<D:\Pictures\${filename#;DateFmt('%Y')}\${filename#;DateFmt('%m')}\$FileName" "D:\Pictures\2012-05-24" -r
But this gives an Error converting date/time for 'filename' error. Which makes sense, how do I tell it to format only the first 8 digits of the filename to a date?
The reason I want to use ExifTool for this, is that I actually am going to further refine this statement to only do this for files that don't already have a datetimeoriginal metadata set, so exiftool can filter these out...something like this qualifier:
exiftool '-datetimeoriginal<filemodifydate' -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00")) and ($filetype eq "JPEG")'
But instead of setting the datetimeoriginal to the filemodifydate, I need to set it to a date formatted from the filename.
To set DateTimeOriginal from the filename, the command is as simple as
exiftool "-DateTimeOriginal<Filename" -if "not $datetimeoriginal or ($datetimeoriginal eq '0000:00:00 00:00:00')" -ext jpg DIR
This is based upon Exiftool FAQ #5 which says "ExifTool is very flexible about the actual format of input date/time values when writing, and will attempt to reformat any values into the standard format unless the -n option is used. Any separators may be used (or in fact, none at all). The first 4 consecutive digits found in the value are interpreted as the year, then next 2 digits are the month, and so on."
I removed the $filetype eq "JPEG" portion of your example and replaced it with the -ext option as checking against Filetype is a poor way to limit the files processed, as exiftool will still process and extract all metadata from every file to perform the check.
Take note that the .mp4 filetype, as shown in your example, cannot hold the DateTimeOriginal tag. Instead, you'll have to use something like CreateDate. Also take note that exiftool has limited ability to write to video files.
Because the filename isn't a timestamp type tag, you can't use the -d (dateformat) option as you discovered. Instead, you would have to use the Advanced formatting feature to split up the filename. Given the first example filename, your command would be:
exiftool "-testname<D:\Pictures\${filename;s/^(\d{4}).*/$1/}\${filename;s/^\d{4}(\d\d).*/$1/}\%F" "D:\Pictures\2012-05-24" -r
The -d "%Y-%m-%d" part is removed as it wasn't used in your example. ${filename;s/^(\d{4}).*/$1/} uses regex to match the first four digits of the filename and strip the rest. ${filename;s/^\d{4}(\d\d).*/$1/} strips the first four digits, matches the next two, and strips the rest of the filename. %F is an exiftool variable for the filename+ext used for the various exiftool file operations such as renaming and moving (but not available in tag processing).

Wildcards and the MOVE command in a batch file - Wildcard not recognised as such

I have a batch file with the following line in it:
move d:\cdr\C0*.%yyyy%-%mm%-%dd%*.csv d:\CDRArchive\%yyyy%%mm%\
where the variables yyyy mm and dd are for their resective parts of a given date. When I run this, the batch file parses the variables out correctly, but I doesn't recognise the wildcard character *, so I get the following line:
> move d:\cdr\archive\C0*.2013-09-08*.csv d:\CDRArchive\201309\
A duplicate file name exists, or the file
cannot be found.
Any help is much appreciated.
It works fine, once the target folder is created. Note that the error message you supplied shows that the filespec is wrong or the folder is wrong. The error message you get when they are right is shown below. (tested in Windows 8)
d:\>move d:\cdr\C0*.2000-10-01*.csv d:\CDRArchive\200010\
Cannot move multiple files to a single file.
d:\>md d:\CDRArchive\200010\
d:\>move d:\cdr\C0*.2000-10-01*.csv d:\CDRArchive\200010\
d:\cdr\C0abc.2000-10-01.aaa.csv
d:\cdr\C0abc.2000-10-01.bbb.csv
d:\cdr\C0abc.2000-10-01.ccc.csv
3 file(s) moved.

Teradata FastExport Script - cannot get it to run - The system cannot find the file specified

I am brand new to teradata. I wrote a fastexport script to take some data from a db and export it to some excel files.
The script is all good. I just can't run it!
I am running the cmd fexp < C:\Documents\ScriptName (that is not the actual path)
Where ScriptName is a .txt file containing the script.
I get the error:
"The system cannot find the file specified"
I have tried changing the location of the file and such but always get the same error.
What am I missing here?
I found the answer. The correct command is:
fexp < "C:\Path to file\ScriptName.txt"

Resources