filemorph

Check-in [fb8785f34d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Start work on version 3.0
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:fb8785f34d73c173a4394c33379568d4c39377ec
User & Date: kevin 2018-08-17 02:12:49
Context
2018-08-20
17:57
Unit test, rev bump for 3.0 and Windows check-in: 6c7f57f091 user: kevin tags: trunk
2018-08-17
02:12
Start work on version 3.0 check-in: fb8785f34d user: kevin tags: trunk
2017-06-21
03:52
Tweak to regproc check-in: e216eb7a36 user: kevin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to filemorph.pl.

1
2
3
4
5
6
7
8
9
10
..
59
60
61
62
63
64
65
66








67
68
69
70
71
72
73
..
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
...
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
# FileMorph: Rename files, edit attributes

#Copyright (C) 2017 WordTech Communications LLC

#MIT license

#let's get started

use FindBin qw($Bin);
use Config;
................................................................................
Tkx::package_require('xplat');

if ($IS_AQUA) {
    Tkx::package_require('fullscreen');
    Tkx::package_require('aem');
    Tkx::package_require('cocoaprint');
    Tkx::package_require('windowlist');
}









#initialize variables
our $folder;
our $sourceext;
our $targetext;
our $targetstring;
our $srcstring;
................................................................................

if ($IS_AQUA) {
    Tkx::interp_alias( "", "::tk::mac::OpenDocument", "", [ \&openDoc ] );
    Tkx::interp_alias( "", "::tk::mac::ShowHelp",     "", [ \&showHelp ] );
    Tkx::interp_alias( "", "bgerror",                 "", [ \&errlog ] );
}

if ($IS_WINDOWS) {
    Tkx::package_require("twapi");
}

#draw the GUI
our $mw = Tkx::widget->new(".");
Tkx::wm_title( $mw, "FileMorph" );
$mw->g_wm_withdraw;
if ($IS_WINDOWS) {
    $mw->g_wm_protocol( WM_DELETE_WINDOW => \&shutdown );
    $mw->g_wm_iconphoto( -default => $icon );
................................................................................
sub Tkx::tkAboutDialog {

    Tkx::tk___messageBox(
        -parent  => $mw,
        -title   => "About FileMorph",
        -icon    => "info",
        -message => "FileMorph: File Modification Tool",
        -detail  => "Version 2.9\n(c) 2017 WordTech Communications LLC"
    );
}

#handle errors in Tk
sub errlog {
    my $msg = shift;
    if ($IS_AQUA) {


|







 







|
>
>
>
>
>
>
>
>







 







<
<
<
<







 







|







1
2
3
4
5
6
7
8
9
10
..
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
...
106
107
108
109
110
111
112




113
114
115
116
117
118
119
...
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
# FileMorph: Rename files, edit attributes

#Copyright (C) 2018 WordTech Communications LLC

#MIT license

#let's get started

use FindBin qw($Bin);
use Config;
................................................................................
Tkx::package_require('xplat');

if ($IS_AQUA) {
    Tkx::package_require('fullscreen');
    Tkx::package_require('aem');
    Tkx::package_require('cocoaprint');
    Tkx::package_require('windowlist');
  }

if ($IS_WINDOWS) {
  Tkx::package_require('dde');
  Tkx::dde_servername('FileMorph');
}
  

  

#initialize variables
our $folder;
our $sourceext;
our $targetext;
our $targetstring;
our $srcstring;
................................................................................

if ($IS_AQUA) {
    Tkx::interp_alias( "", "::tk::mac::OpenDocument", "", [ \&openDoc ] );
    Tkx::interp_alias( "", "::tk::mac::ShowHelp",     "", [ \&showHelp ] );
    Tkx::interp_alias( "", "bgerror",                 "", [ \&errlog ] );
}





#draw the GUI
our $mw = Tkx::widget->new(".");
Tkx::wm_title( $mw, "FileMorph" );
$mw->g_wm_withdraw;
if ($IS_WINDOWS) {
    $mw->g_wm_protocol( WM_DELETE_WINDOW => \&shutdown );
    $mw->g_wm_iconphoto( -default => $icon );
................................................................................
sub Tkx::tkAboutDialog {

    Tkx::tk___messageBox(
        -parent  => $mw,
        -title   => "About FileMorph",
        -icon    => "info",
        -message => "FileMorph: File Modification Tool",
        -detail  => "Version 3.0\n(c) 2018 WordTech Communications LLC"
    );
}

#handle errors in Tk
sub errlog {
    my $msg = shift;
    if ($IS_AQUA) {

Changes to scriptlibs/machelp/help.txt.

65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
..
88
89
90
91
92
93
94
95





























































96
97
98



99
100
101
102
103
104
105

[fm-timedate]

-------------------
title: Scripting FileMorph
alias: Scripting

'''Mac Scripting'''

FileMorph can be automated via an AppleScript. To target FileMorph via AppleScript, use the following syntax:

    tell app "FileMorph" 
        command parameter
    end tell

The command is the action FileMorph will be performing, and the parameter--not required in all cases--is the value that will be manipulated. The list of commands and their parameters is below: 

 * set_directory_path ''path'': Set the directory for operations.
 * set_file_path ''path'': Set the file for operations. 
 * set_old_extension ''old extension'': Set the file extension to be changed. 
 * set_new_extension ''new extension'': Set the new file extension.
 * change_extension: Change the file extension.
 * set_old_text ''text'': Set the old text string to change. 
................................................................................
 * set_new_text ''text'': Set the replacement string. 
 * change_text: Change the text.
 * set_added_text ''text'': Set the text to be added to file names.
 * set_prefix_or_suffix ''0 or 1'': Select whether the text will be added to the beginning or name of the file name.
 * add_text: Add the text.
 * set_time ''MM/DD/YYYY'': Set the time to be changed to in MM/DD/YYYY format. 
 * change_file_time: Change the file modification time. 






























































'''Windows Scripting'''
 
Windows scripting is being developed for a future release of FileMorph on Windows.




-------------------
title: Help
alias: Help

FileMorph provides comprehensive user documentation from the "Help" menu, and also provides tooltips for the toolbar buttons. Additional user support is available via the "Contact Code by Kevin" item in the Help menu; and the website link in the help menu.








|
<
<
<
<
<
<
<
<







 







|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


<
>
>
>







65
66
67
68
69
70
71
72








73
74
75
76
77
78
79
..
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150

151
152
153
154
155
156
157
158
159
160

[fm-timedate]

-------------------
title: Scripting FileMorph
alias: Scripting

FileMorph can be automated on both the Mac and Windows. The list of commands and their parameters is below: 









 * set_directory_path ''path'': Set the directory for operations.
 * set_file_path ''path'': Set the file for operations. 
 * set_old_extension ''old extension'': Set the file extension to be changed. 
 * set_new_extension ''new extension'': Set the new file extension.
 * change_extension: Change the file extension.
 * set_old_text ''text'': Set the old text string to change. 
................................................................................
 * set_new_text ''text'': Set the replacement string. 
 * change_text: Change the text.
 * set_added_text ''text'': Set the text to be added to file names.
 * set_prefix_or_suffix ''0 or 1'': Select whether the text will be added to the beginning or name of the file name.
 * add_text: Add the text.
 * set_time ''MM/DD/YYYY'': Set the time to be changed to in MM/DD/YYYY format. 
 * change_file_time: Change the file modification time. 

'''Mac Scripting'''

Automating the application on macOS can be done via AppleScript. Type this script (with appropriate modification of directories to reflect your system) into AppleScript Editor and run it, or save the script as "test.applescript" and run "osascript test.applescript" from the command line: 

   tell application "Finder"
      try
         delete "Macintosh HD:Users:kevin:Programming:filemorph:unit files:"
         delete "Macintosh HD:Users:kevin:Programming:filemorph:unitfiles:"
      on error
         log
      end try
      make new folder at folder "FileMorph" of folder "Programming" of home with properties {name:"unit files"}
      duplicate every file of folder "testsource" of folder "FileMorph" of folder "Programming" of home to "Macintosh HD:Users:kevin:Programming:filemorph:unit files:"
      make new folder at folder "FileMorph" of folder "Programming" of home with properties {name:"unitfiles"}
      duplicate every file of folder "testsource" of folder "FileMorph" of folder "Programming" of home to "Macintosh HD:Users:kevin:Programming:filemorph:unitfiles:"
   end tell

   tell application "FileMorph.app"
   
      set a to alias "Macintosh HD:Users:kevin:Programming:filemorph:unit files:"
      --file names with spaces are tricky; escape spaces as below
      --set p to quoted form of POSIX path of a
      set p to "/Users/kevin/Programming/filemorph/unit\\ files"
      set_directory_path (p)
      set_old_extension ("jpg")
      set_new_extension ("gif")
      change_extension
      set_old_text ("test")
      set_new_text ("foo")
      change_text
      set_added_text ("bar")
      set_prefix_or_suffix 1
      add_text
      set_time ("12/15/1999")
      change_file_time
   
      tell application "Finder" to open alias "Macintosh HD:Users:kevin:Programming:filemorph:unit files:"
   
      delay 3
   
      set a to alias "Macintosh HD:Users:kevin:Programming:filemorph:unitfiles:"
      set p to "/Users/kevin/Programming/filemorph/unitfiles"
      --open p
      set_directory_path (p)
      set_old_extension ("txt")
      set_new_extension ("sh")
      change_extension
      set_old_text ("test")
      set_new_text ("best")
      change_text
      set_added_text ("my")
      set_prefix_or_suffix 0
      add_text
      set_time ("12/25/2006")
      change_file_time
      
      tell application "Finder" to open alias "Macintosh HD:Users:kevin:Programming:filemorph:unitfiles:"

   end tell


'''Windows Scripting'''
 

Automating the application on Windows can be done using the Dynamic Data Exchange (DDE) protocol. The DDE protocol has several components, including a "Service," "Topic," and "Items." In FileMorph, the Service name is always TclEval (because that is the underlying name that the Tcl interpreter supports), the Topic name is FileMorph, and Items (data or return values) are not currently required. 

There are various programming languages on Windows in which one can write a DDE client to automate a DDE application, including Tcl, Python, VBA, C/C++, and others. An easy way to automate TextSweep from the command line is to install Chris Oldwood's free DDE Command tool from [http://www.chrisoldwood.com/win32.htm]. The tool can then be incorporated into a batch script such as the following: 

-------------------
title: Help
alias: Help

FileMorph provides comprehensive user documentation from the "Help" menu, and also provides tooltips for the toolbar buttons. Additional user support is available via the "Contact Code by Kevin" item in the Help menu; and the website link in the help menu.