我的最终目标是将所有相关文件从一个文件夹复制到另一个文件夹.所以我们有C:\Users\Tool\Desktop\test\oldStuff.在文件夹中oldStuff我们有更多的文件夹以及一些mp3,mp4和txt文件.
现在,我希望做的是复制所有的MP4文件,这些文件比GB较小C:\Users\Tool\Desktop\test\New_Stuff_Less_than_a_Gig,和.MP4是比GB到更大的文件C:\Users\Tool\Desktop\test\New_STuff_Bigger_than_a_Gig.
我觉得这很容易,但我错了.到目前为止有这个,现在不担心文件类型所以只是做了它*.*
procedure TForm4.Button1Click(Sender: TObject);
var
f: TSearchRec;
Dir: string;
begin
if not SelectDirectory(Dir,widestring(Dir),Dir) then Exit;
FileMode:=0;
if FindFirst(Dir+'\*.*',faAnyFile,f) = 0 then
repeat
try
if (f.Attr and faDirectory ) < $00000008 then
CopyFile(PChar(Dir+'\'+f.Name),PChar
('C:\Users\Tool\Desktop\test\new\'+f.Name),false);
except
on e: exception do
ShowMessage(E.Message);
end;
until findNext(f) <> 0
end;
Run Code Online (Sandbox Code Playgroud)
它将复制所选文件夹中的任何内容,但不会从所选文件夹中的文件夹中复制任何内容.例如,如果我们有C:\Users\Tool\Desktop\test\oldStuff\movie.mp4它将复制该Movie.mp4文件,但如果我们有C:\Users\Tool\Desktop\test\oldStuff\movies\Movie.mp4它将不会复制该Movie.mp4文件.我虽然可以做这样的事情
CopyFile.size < 1000 (PChar('C:\Users\Tool\Desktop\test\oldStuff\*.*'+f.Name),
PChar('C:\Users\Tool\Desktop\test\new_Stuff\'+f.Name),false) …Run Code Online (Sandbox Code Playgroud) 我试图从我的电影中对我的电视节目进行排序,我认为最好的方法是通过电视节目季节和剧集标记来识别它们.
我所有的电视节目都有以下格式S00E00.
尝试了以下
if (Pos(IntToStr(I), SR.Name) > 0) and (Pos('S', SR.Name) > 0) then
result := true;
Run Code Online (Sandbox Code Playgroud)
但这不起作用,因为如果一部电影有一个标题含有's'和任何数字,它会复制它.
需要像字符串pos"字母s后跟整数,整数,字母e,整数,整数"那样结果:= true
无论剧集是S01E03还是S09E12都会复制.
.........................................
2015年12月22日编辑
.........................................
谢谢雷米认为它不那么容易.
这是澄清的程序.
procedure TForm7.TvShowCopy (Format: string);// Format would be .mp4 or whatever you're using but since the procedure searches for a name matching "S00E00" format I suppose you wouldn't need the format and could just use *.*.
begin
aTvshowFiles := TDirectory.GetFiles(STvshows,format,// aTVshowfiles is a TStringDynArray , STvshows is the Source directory for the TV shows.
TSearchOption.soAllDirectories, …Run Code Online (Sandbox Code Playgroud) 经过很长一段时间后......决定寻求帮助.
我正在尝试阅读发送到Delphi中的Tmemo的最后一行.我正在向开发人员逐个发送代码行.登上开发者.电路板每次都需要发送不同的代码行.我的最终目标是回读dev的最后一行.董事会发回来.
例如
设置ATT = 7 --- >> \发送到dev.板
开发.董事会回复
确定<----- \从dev收到.板
发送下一行代码.
要么
呃
再次发送"set att = 7"命令.
到目前为止,我已经掌握了大部分需要工作的东西.我只是不能让Delphi阅读tmemo的最后一行.
我试过了
procedure TReaderProgrammer.Button3Click(Sender: TObject );
var
RxData : string;
LL : string;
ll2: system.integer;
begin
LL:= memorxdata.lines.count.ToHexString;
LL2:=memorxdata.Lines.Count;
if ComPort1.Connected then
begin
showmessage(ll);
ComPort1.WriteStr(memorxdata.Lines[ll2]+#13+#10);
end;
end;
Run Code Online (Sandbox Code Playgroud)
showmessage只供我自己参考...我知道它反弹它再次收到的数据仅供参考.
奇怪的是它有时会起作用,而那些线条.伯爵有时会反弹回信,所以我想我会以完全错误的方式解决这个问题......