아담,
이 시나리오가 시나리오와 일치하는지 확신 할 수 없지만 몇 년 전에 비슷한 문제가있었습니다. 파일 서버에서 매일 새 디렉토리가 만들어졌으며 해당 폴더에 해당 날짜의 파일이 포함되었습니다. 문제는 시간이 일관 적이 지 않다는 것이 었습니다. 폴더 (디렉토리) 이름의 시간은 해당 날짜의 첫 번째 파일이 도착한 날짜 시간입니다. 따라서 특정 시간은 알려지지 않았습니다.
가장 단순한 JSL 명령은 폴더 = 디렉토리의 파일 ( "경로") 재발을 사용하지 마십시오. 그런 다음 JSL을 사용하여 시작되었거나 오늘 날짜가 들어있는 폴더를 검색하십시오. 그러나 완벽하게 작동하는 서버에는 폴더가 "bazillions"되어 성능이 매우 느립니다. 나는 Windows 운영 체제로 작업하므로 cmd.exe와 함께 Run Program을 사용하여 사용자 지정 dir 명령을 실행했습니다. 예를 들어,이 MS Dir 명령
dir / a : d / o : -dc : \ temp \ jsl *
jsl로 시작하는 폴더 이름을 가진 나의 c : \ temp 디렉토리에 존재하는 가장 최근의 것부터 가장 오래된 것 (/ o : -d 순서 역순으로)까지 나열된 모든 폴더 (/ a : d 모든 디렉토리)를 반환합니다. 오늘 날짜를 사용하여 목록을 좁힐 수 있습니다.
내 "bazillion"폴더 문제에 대해 검색해야하는 디렉토리 이름 구조는 20180524 * something_somethingelse와 같았습니다. 백업이 폴더 빌드를 다시 시작할 때가 있었기 때문에 때로는 2와 매우 드물게 3 개의 값을 얻을 수있었습니다. 하지만 그것은 역순이기 때문에 목록의 첫 번째 항목은 대상 폴더였습니다.
내 스크립트에서 대상 폴더를 얻은 후에는 알 수없는 특정 시간대의 디렉토리가 있고 이제는 각 파일을 처리하고 보고서를 원격으로 생성 할 수 있으므로 Directory In Files ()를 사용할 것입니다. ).
Mac 사용자 인 경우 Jim의 제안 만 훌륭합니다. 파일의 inDirectory ()에서 반환 한 목록의 각 파일에 대해 오늘 날짜가 포함 된 파일을 검색하고 둘 이상인 경우 만든 날짜를 가져와 최신 날짜를 찾습니다.
Windows를 사용하고 있고 성능 문제를 해결하려면 JMP 설치 디렉토리에 모든 폴더를 가져 오는 방법을 보여주는 스크립트가 있습니다. [이 예제처럼 간단하게 메모하면 Directory ()의 파일이 가장 적합한 솔루션입니다.]
// Get the full path for the JMP Install Directory
jmpDir = Convert File Path( "$JMP_Home", Windows );
Show( jmpDir );
// Build the DOS "dir" command
// dir /-C /T:C /S "C:\Program Files\SAS\JMPPRO\13\Samples\Data\*.J*" > c:\temp\dirOut_rp.txt
// --- DOS requires quoted file paths if the path includes spaces Program Files has a space
//this has no output file and /b only the directory name is returned
cmd_txt ="\[/c dir /a:d /b /-c /o:-d "]\"
|| jmpDir //will replace it with the full path of your installed JMP directory
||"\[* ]\";
show(cmd_txt ); //see the log file
//results returned as text
rpobj = RunProgram(Executable("CMD.EXE" ),
Options({Eval(cmd_txt)}),
ReadFunction("text")
);
show(rpobj);
if(length(rpobj) >0, dirList= words(rpobj,"\!N") );
show(dirList);
/*
{"ExcelProfiler", "imagemaps", "Tip of the Day", "Help", "Resources", "pptx",
"Flash", "Documentation", "tkext", "Scoring", "Samples", "Web", "Maps"}
*/
//____________________________________________________________________________________________
//alternate command to return information to a file
outDir = "c:\temp\dirOut_rp.txt";
cmd_txt ="\[/c dir /a:d /b /-c /o:-d "]\"
|| jmpDir //will replace it with the full path of your installed Sample Data directory
|| "\[*" > ]\"
|| outDir;
show(cmd_txt ); //see the log file
t0 = Today();
rpobj = RunProgram(Executable("CMD.EXE" ),
Options({Eval(cmd_txt)}),
ReadFunction("text")
);
//--- ReadFunction is reading statements from the OS, it reads until the program quits.
// This command suspends subsequent JSL until executable has completed the tasks.
//==== Show results=============================================================================
// A couple of "checks" that you may employ here if the file does not does not exist or if it is older than expected
If( !File Exists( outDir ) | (Creation Date( outDir ) - t0 > 10),
Caption( "There was a problem with the dir command, it did not run. Aborting..." );
Wait( 4 );
Caption( Remove );
Throw();
);
// Open the results file as text stored in column 1
dir_dt = Open(
outDir,
columns( Name( "Dir results" ) = Character ),
Import Settings(
End Of Line( CRLF ),
End Of Field( CRLF ), // ensures only 1 column
Strip Quotes( 1 ),
Use Apostrophe as Quotation Mark( 1 ),
Scan Whole File( 1 ),
Treat empty columns as numeric( 0 ),
Labels( 0 ),
Data Starts( 1 ),
Lines To Read( All ),
Year Rule( "10-90" )
)
);
파일을 가져올 디렉토리를 지정하는 방법을 지정하지 않았으므로 방금 Pick Directory ()를 사용했습니다. 저는 여러분이 표준 폴더를 가지고 있다고 가정하고 있습니다.이 경우 Pick Directory ()를 무시할 수 있습니다 :
folder = "<YOUR folder="" path="">";</YOUR>
짐,
당신의 도움을 주셔서 감사합니다,
pick 디렉토리 기능이 비 프롬프트를 실행할 수 있는지 모르겠습니다. 내 스크립트는 사용자의 개입없이 백그라운드에서 매일 실행해야합니다.
감사
다음은 간단한 파일로서 여러분의 요구를 충족시키는 파일을 찾는 방법에 대한 아이디어를 줄 것입니다.
Names Default To Here( 1 );
folder = Pick Directory();
// Get all of the files in the folder
FileList = Files In Directory( folder );
// Create the known part of the files to look for
Header = Char( Day( Today() ) ) || "_" || Char( Month( Today() ) ) || "_" ||
Char( Year( Today() ) - 2000 ) || "_";
// Loop through the found files and eliminate all that do not
// match the pattern we are looking for
For( i = N Items( FileList ), i >= 1, i--,
If( Left( FileList, Length( Header ) ) != Header,
FileList = Remove( FileList, i, 1 )
)
);