我需要一些帮助来创建基于一堆子文件夹的输出文件(或“报告”)。我想每晚通过电子邮件将此报告发送给自己(我可以处理该文件的电子邮件,但不确定如何创建实际文件)。
我的数据结构:
我想做什么:
创建单个.txt或.csv文件,其中包含每个客户端文件夹中最新的TFX _ * .log文件列表(只是最新的 - 不是所有15个文件)。像这样:
目录名称|文件名|修改日期
我只需要帮助2号。
这是我到目前为止所拥有的:
:: Copying data
XCOPY "%source1%" "%destination%\TFX Logs\" /s /y
XCOPY "%source2%" "%destination%\TFX Logs\" /s /y
XCOPY "%source3%" "%destination%\TFX Logs\" /s /y
:: Deleting old output file before creating new one
DEL "%destination%\*.txt"
:: Creating new output file
powershell "& '%destination%\ListFiles.ps1'"
REN "%destination%\ImportReport.txt" ImportReport_%tday%.txt
我的Powershell脚本如下所示:
Get-ChildItem "..Daily Report\TFX Logs\" -recurse -file | Where{$_.LastWriteTime -gt (Get-Date).AddDays(-1)} | Out-File "..Daily Report\ImportReport.txt"
我现在得到的是:
(如果可能,我只想使用上面#2中指定的结构从每个文件夹中获取最新文件)
Directory: ..\TFX Logs\Client1
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 4/22/2015 3:06 AM 329 TFX_db21_1522040304.log
Directory: ..\TFX Logs\Client2
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 4/22/2015 12:22 AM 331 TFX_db4_1522040017.log
Directory: ..\TFX Logs\Client3
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 4/21/2015 8:03 PM 329 TFX_db4_1521042002.log
Cliff's Notes:
我想将PowerShell的输出重新排列为:
目录名称(目录)|文件名(名称)|上次修改日期(LastWriteTime)
没有其他所有东西和所有的空白区域。只是一个很好的逐行输出。
此外,如果可能,如果其中有一个空文件夹(或者文件夹中的文件超过15天),仍然要在报告文件中显示,但没有记录。这样我就会知道,嘿,这个客户端已经运行了一段时间,需要进行检查。
2015年4月29日更新
Magoo的建议显示了承诺,但对我没有用。它没有做任何事情。任何人都有任何关于如何改进我已经拥有的东西的想法吗?
答案 0 :(得分:0)
u:
这可以解决您的问题。
为了进行测试,我使用了destdir
驱动器和.txt
作为目标diectoryname。
只需删除目标ECHO
文件,然后查看目录名列表,调用
复制日志文件所需的XCOPY命令仅用于ECHO(XCOPY
以进行测试。 在您确认命令正确后,将XCOPY
更改为>nul
以实际复制文件。附加1 file copied
以取消报告消息(例如tday
)
切换到目标目录
function checkPostcode(postcode) {
$('.postcode_success').hide();
$('.postcode_fail').hide();
postcode = postcode.replace(/\s/g, '');
postcode = postcode.toUpperCase();
var postcodes = ["CV370AA","CV370AG","CV370AL","CV370AN","CV370AP","CV370AQ","CV370AR","CV370AT","CV370AU","CV370AX","CV370BB","CV370BD","CV370BE","CV370BG","CV370BH","CV370BJ","CV370BL","CV370BQ","CV370DA","CV370DB","CV370DD","CV370DE","CV370DF","CV370DH","CV370DJ","CV370DL","CV370DN","CV370DP","CV370DQ","CV370DQ","CV370DR","CV370DS","CV370DS","CV370DT","CV370DU","CV370DW","CV370DX","CV370DZ","CV370EA","CV370ED","CV370EE","CV370EF","CV370EQ","CV370NP","CV370NR","CV370NS","CV370NT","CV370QE","CV370QP","CV370QR","CV370QS","CV370QT","CV370QU","CV370QZ","CV370RE","CV370RF","CV370RH","CV370RR","CV370RS","CV370RU","CV370RX","CV370RY","CV370RZ","CV370SG","CV370TA","CV370TB","CV370TD","CV370TE","CV370TF","CV370TG","CV370TH","CV370TJ","CV370TL","CV370TN","CV370TP","CV370TQ","CV370TS","CV370TT","CV370TU","CV370TW","CV370TX","CV370UB","CV370UD","CV370UE","CV370UF","CV370UG","CV370UH","CV376AU","CV376BA","CV376BD","CV376BE","CV376BG","CV376BH","CV376BJ","CV376BL","CV376BN","CV376BP","CV376BQ","CV376BS","CV376BW","CV376BX","CV376BY","CV376DA","CV376DB","CV376DD","CV376DE","CV376DF","CV376DH","CV376DJ","CV376DL","CV376DN","CV376DQ","CV376DR","CV376DS","CV376DT","CV376DU","CV376DW","CV376DY","CV376EB","CV376EE","CV376EF","CV376EL","CV376EN","CV376EP","CV376EQ","CV376EW","CV376EZ","CV376FB","CV376FE","CV376FF","CV376FL","CV376FR","CV376GD","CV376GF","CV376GH","CV376GN","CV376GP","CV376GR","CV376GS","CV376GW","CV376GX","CV376HA","CV376HB","CV376HD","CV376HE","CV376HF","CV376HG","CV376HH","CV376HL","CV376HN","CV376HQ","CV376HS","CV376HT","CV376HW","CV376JA","CV376JE","CV376JF","CV376LA","CV376LE","CV376LF","CV376LN","CV376LP","CV376LS","CV376LT","CV376LU","CV376LW","CV376LX","CV376LY","CV376LZ","CV376NA","CV376ND","CV376NG","CV376NH","CV376NJ","CV376NL","CV376NR","CV376NW","CV376NY","CV376NZ","CV376PA","CV376PB","CV376PD","CV376PE","CV376PF","CV376PG","CV376PH","CV376PN","CV376PQ","CV376PS","CV376PT","CV376PX","CV376QB","CV376QT","CV376QW","CV376QY","CV376QZ","CV376RA","CV376RB","CV376RE","CV376RF","CV376RJ","CV376RN","CV376RP","CV376RR","CV376RS","CV376RT","CV376RW","CV376RY","CV376RZ","CV376SA","CV376SB","CV376SE","CV376SF","CV376SG","CV376SH","CV376SJ","CV376SL","CV376SN","CV376SP","CV376SQ","CV376SR","CV376ST","CV376SU","CV376SW","CV376SX","CV376SY","CV376SZ","CV376TA","CV376TB","CV376TD","CV376TE","CV376TF","CV376TG","CV376TH","CV376TJ","CV376TL","CV376TN","CV376TP","CV376TQ","CV376TR","CV376TS","CV376TT","CV376TU","CV376TY","CV376UA","CV376UB","CV376UF","CV376UH","CV376UJ","CV376UN","CV376UP","CV376UQ","CV376UR","CV376UT","CV376UU","CV376UW","CV376UY","CV376WG","CV376XA","CV376XB","CV376XD","CV376XE","CV376XF","CV376XG","CV376XH","CV376XJ","CV376XL","CV376XN","CV376XP","CV376XQ","CV376XR","CV376XS","CV376XT","CV376XU","CV376XW","CV376XX","CV376XY","CV376XZ","CV376YA","CV376YB","CV376YD","CV376YE","CV376YF","CV376YG","CV376YJ","CV376YN","CV376YP","CV376YQ","CV376YS","CV376YT","CV376YW","CV376YY","CV376YZ","CV377AA","CV377AB","CV377AD","CV377AE","CV377AF","CV377AG","CV377AH","CV377AJ","CV377AL","CV377AN","CV377AP","CV377AQ","CV377AR","CV377AS","CV377AT","CV377AU","CV377AX","CV377AY","CV377AZ","CV377BA","CV377BB","CV377BD","CV377BE","CV377BF","CV377BG","CV377BP","CV377BQ","CV377BS","CV377BS","CV377BT","CV377BU","CV377BW","CV377BY","CV377BZ","CV377DA","CV377DB","CV377DD","CV377DE","CV377DF","CV377DH","CV377DN","CV377DP","CV377DQ","CV377DR","CV377DS","CV377DT","CV377DU","CV377DW","CV377DX","CV377DY","CV377EA","CV377EB","CV377EE","CV377EF","CV377EG","CV377EH","CV377EJ","CV377EL","CV377EN","CV377EP","CV377EQ","CV377ER","CV377ES","CV377ET","CV377EU","CV377EW","CV377EX","CV377EY","CV377EZ","CV377HA","CV377HB","CV377HD","CV377HE","CV377HF","CV377HG","CV377HH","CV377HJ","CV377HL","CV377HN","CV377HP","CV377HQ","CV377HR","CV377HS","CV377HT","CV377HU","CV377HW","CV377HX","CV377HY","CV377HZ","CV377JA","CV377JB","CV377JD","CV377JE","CV377JF","CV377JG","CV377JH","CV377JJ","CV377JL","CV377JN","CV377JP","CV377JQ","CV377JR","CV377JS","CV377JT","CV377JU","CV377JW","CV377JX","CV377JY","CV377JZ","CV377LA","CV377LB","CV377LD","CV377LE","CV377LF","CV377LG","CV377LH","CV377LJ","CV377LL","CV377LN","CV377LP","CV377LQ","CV377LR","CV377LS","CV377LU","CV377LW","CV377LX","CV377LY","CV377LZ","CV377NE","CV377NF","CV377NG","CV377NH","CV377NL","CV377PF","CV377PL","CV377PP","CV377PQ","CV377PR","CV377PS","CV377PT","CV377PU","CV377PW","CV377PX","CV377PY","CV377PZ","CV377QA","CV377QB","CV377QD","CV377QF","CV377QG","CV377QH","CV377QJ","CV377QL","CV377QN","CV377QP","CV377QQ","CV377QR","CV377QS","CV377QT","CV377QU","CV377QX","CV377QZ","CV377RA","CV377RB","CV377RE","CV377RF","CV377RG","CV377RH","CV377RJ","CV377RL","CV377RN","CV377RP","CV377RQ","CV377RR","CV377RT","CV377RW","CV377SA","CV377UQ","CV378HP","CV378HR","CV378HW","CV378LT","CV378LU","CV378LX","CV378LY","CV379AA","CV379AB","CV379AD","CV379AE","CV379AG","CV379AH","CV379AJ","CV379AL","CV379AN","CV379AP","CV379AR","CV379AS","CV379AT","CV379AU","CV379AX","CV379AZ","CV379BA","CV379BB","CV379BD","CV379BE","CV379BH","CV379BJ","CV379BL","CV379BP","CV379BQ","CV379BS","CV379BT","CV379BW","CV379BZ","CV379DA","CV379DB","CV379DD","CV379DE","CV379DF","CV379DG","CV379DJ","CV379DL","CV379DN","CV379DP","CV379DQ","CV379DR","CV379DS","CV379DT","CV379DU","CV379DW","CV379DX","CV379DY","CV379DZ","CV379EA","CV379EB","CV379ED","CV379EE","CV379EF","CV379EG","CV379EL","CV379EN","CV379EP","CV379ER","CV379ES","CV379ET","CV379EU","CV379EW","CV379EX","CV379EY","CV379FA","CV379FB","CV379FD","CV379FE","CV379FF","CV379FG","CV379FL","CV379FN","CV379FP","CV379FR","CV379FS","CV379FU","CV379HA","CV379HB","CV39HD","CV379HE","CV379HF","CV379HG","CV379HH","CV379HJ","CV379HL","CV379HN","CV379HP","CV379HQ","CV379HR","CV379HS","CV379HT","CV379HU","CV379HX","CV379HZ","CV379JB","CV379JE","CV379JF","CV379JG","CV379JH","CV379JJ","CV379JL","CV379JN","CV379JP","CV379JQ","CV379JR","CV379JS","CV379JT","CV379JU","CV379JW","CV379JX","CV379JY","CV379JZ","CV379LA","CV379LB","CV379LD","CV379LE","CV379LF","CV379LG","CV379LH","CV379LJ","CV379LL","CV379LN","CV379LP","CV379LR","CV379LS","CV379LT","CV379LU","CV379LW","CV379LX","CV379LY","CV379LZ","CV379NA","CV379ND","CV379NE","CV379NG","CV379NH","CV379NX","CV379NZ","CV379PA","CV379PB","CV379PD","CV379PE","CV379PF","CV379PG","CV379PH","CV379PJ","CV379PL","CV379PN","CV379PP","CV379PQ","CV379PU","CV379PW","CV379PX","CV379PY","CV379QA","CV379QB","CV379QD","CV379QE","CV379QG","CV379QH","CV379QJ","CV379QL","CV379QQ","CV379QS","CV379QT","CV379QW","CV379QX","CV379QY","CV379RP","CV379RZ","CV379SE","CV379SF","CV379YU","CV379YX"]
var result = jQuery.inArray(postcode,postcodes) > -1;
if (result) $('.postcode_success').show()
else $('.postcode_fail').show();
}
)