• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

IllustratorPackageのWindows版をPerlで作成中


Commit MetaInfo

Revisiond9a9ae8a3cab2320ccd6b9667cb3b10e4e91e47a (tree)
Time2012-10-09 14:51:54
Authormacneko_ayu <macneko.ayu@gmai...>
Commitermacneko_ayu

Log Message

IllustratorPackage_perl.pl modified. $file's value changed command prompt argument.

Change Summary

Incremental Difference

--- a/IllustratorPackage_perl.pl
+++ b/IllustratorPackage_perl.pl
@@ -3,15 +3,15 @@ use warnings;
33 use utf8;
44 use Encode qw/decode encode/;
55 use File::Basename; #ファイルパス分割のため
6-#use File::Spec; #ファイルパス結合のため
76 use File::Copy; #ファイルコピーのため
87
98 # ファイルシステムの設定(デフォルト:Unix)
109 fileparse_set_fstype('MSWin32');
1110
1211 my $temp = "";
13-my $file = "C:/CS4_Test/ごん太.ai";
12+my $file = $ARGV[0];
1413 my @linkfilepath = ($file); #収集するファイルのパスを入れる配列
14+my $errcount = 0;
1515
1616 #デスクトップに現在時刻名のディレクトリを作成
1717 sub mkdir_localtime {
@@ -21,11 +21,11 @@ sub mkdir_localtime {
2121 my $time = "$year-$mon-$mday $hour-$min-$sec";
2222 mkdir $ENV{USERPROFILE}.encode('CP932','/デスクトップ/').$time
2323 or die "Can't make dir: $!";
24- return $ENV{USERPROFILE}.'/デスクトップ/'.$time; #戻り値はエンコードしない
24+ return $ENV{USERPROFILE}.'/デスクトップ/'.$time; #戻り値はencodeしない
2525 }
2626
27-open my $fh, '<', encode('CP932',$file)
28- or die "can't open $file: $!";
27+open my $fh, '<', $file
28+ or die "Can't open $file: $!";
2929
3030 while (my $line = <$fh>) {
3131 if ($line =~/Adobe Illustrator CS2/){
@@ -41,27 +41,36 @@ close $fh; #開いたら閉じる
4141
4242 if ($#linkfilepath > -1) { #配列が空じゃなかったら
4343 my $newdir = mkdir_localtime();
44- my $newdir_CP932 = encode('CP932', $newdir); #エンコードした変数を準備
44+ my $newdir_CP932 = encode('CP932', $newdir); #encodeした変数を準備
4545
4646 foreach my $item (@linkfilepath){
47- my $item_CP932 = encode('CP932', $item); #エンコードした変数を準備
47+ my $item_CP932 = encode('CP932', $item); #encodeした変数を準備
4848
49- if (-f $item_CP932){ #ファイルが存在していたら(-fでファイルの存在確認)
49+ if (-f $item_CP932){ #encode_CP932した結果ファイルが存在していたら(-fでファイルの存在確認)
5050 unless (copy($item_CP932, $newdir_CP932)){ #copyに失敗したら
51- print "can't copy from \"$item_CP932\" to \"".$newdir_CP932."\": $!";
51+ print "Can't copy from \"$item_CP932\" to \"".$newdir_CP932."\": $!";
5252 }
53- } else {
53+ } elsif (-f $item){ #encode_CP932しないでファイルが存在していたら
54+ unless (copy($item, $newdir_CP932)){ #copyに失敗したら
55+ print "Can't copy from \"$item\" to \"".$newdir_CP932."\": $!";
56+ }
57+
58+ } else { #ファイルが存在しなかったらIlustratorファイル直下から探す
5459 my $filedir = dirname($file); #Illustratorファイルの親ディレクトリ取得
5560 my $linkpath = basename($item); #配置ファイルの名前を取得
56-# my $linkfile = File::Spec->catfile($filedir, $linkpath); #結合してファイルパスにする
5761 my $linkfile = $filedir."/".$linkpath; #結合してファイルパスにする
58- $linkfile = decode('utf8', $linkfile); #内部文字列(utf8)にデコードする
62+ $linkfile = decode('utf8', $linkfile); #内部文字列(utf8)にdecodeする
5963 my $linkfile_CP932 = encode('CP932',$linkfile);
6064 unless (copy($linkfile_CP932, $newdir_CP932)){
61- print "can't copy from \"$linkfile_CP932\" to \"$newdir_CP932\" ";
65+ print "Can't copy from \"$linkfile_CP932\" to \"$newdir_CP932\" ";
66+ $errcount ++;
6267 }
6368 }
6469 }
6570 }
6671
67-print "successful!";
72+if ($errcount == 0){
73+ print "Successful!";
74+} else {
75+ print "Done! but can't collected files : $errcount files";
76+}
\ No newline at end of file