改行コード変更(仮)
| 固定リンク
| 固定リンク
| 固定リンク
| 固定リンク
####基本
set numChrID to (id of "A")
-->(*65*)
set strNextChr to character id (numChrID + 1)
-->(*B*)
set numChrID to (id of "A")
set listAalphabet to {}
repeat 52 times
if numChrID > 90 then
set strChr to character id (numChrID - 26)
set strChr to "A" & strChr
else
set strChr to character id numChrID
end if
copy strChr to end of listAalphabet
set numChrID to numChrID + 1
end repeat
log listAalphabet
-->(*A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, AA, AB, AC, AD, AE, AF, AG, AH, AI, AJ, AK, AL, AM, AN, AO, AP, AQ, AR, AS, AT, AU, AV, AW, AX, AY, AZ*)
| 固定リンク
通常は
| 固定リンク
| 固定リンク
| 固定リンク
テキストの改行を取る手っ取り早い方法
| 固定リンク
行番号 | ソース |
---|---|
001 | #!/usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | # |
004 | # |
005 | # |
006 | # |
007 | # com.cocolog-nifty.quicktimer.icefloe |
008 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
009 | |
010 | use AppleScript version "2.8" |
011 | use framework "Foundation" |
012 | use scripting additions |
013 | |
014 | property objMe : a reference to current application |
015 | property objNSString : a reference to objMe's NSString |
016 | property objNSMutableString : a reference to objMe's NSMutableString |
017 | property objNSURL : a reference to objMe's NSURL |
018 | property objNSMutableArray : a reference to objMe's NSMutableArray |
019 | |
020 | property objNSNotFound : a reference to 9.22337203685477E+18 + 5807 |
021 | |
022 | set objFileManager to objMe's NSFileManager's defaultManager() |
023 | |
024 | |
025 | ####ダイアログで使うデフォルトロケーション |
026 | set ocidUserDesktopPath to (objFileManager's URLsForDirectory:(objMe's NSDesktopDirectory) inDomains:(objMe's NSUserDomainMask)) as alias |
027 | |
028 | ####UTIリスト PDFのみ |
029 | set listUTI to {"public.plain-text"} as list |
030 | |
031 | ####ダイアログを出す |
032 | set aliasFilePath to (choose file with prompt "ファイルを選んでください" default location (ocidUserDesktopPath) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias |
033 | |
034 | set strFilePath to POSIX path of aliasFilePath as text |
035 | ####ドキュメントのパスをNSString |
036 | set ocidFilePath to objNSString's stringWithString:strFilePath |
037 | ####ドキュメントのパスをNSURLに |
038 | set ocidNSUrlPath to objNSURL's fileURLWithPath:ocidFilePath |
039 | ####ファイル名 |
040 | set ocidFileName to ocidNSUrlPath's lastPathComponent |
041 | ####拡張子を除いたファイル名 |
042 | set ocidPrefixName to ocidFileName's stringByDeletingPathExtension |
043 | |
044 | ####ファイルを読み取る |
045 | set strReadData to (objNSString's stringWithContentsOfFile:ocidFilePath encoding:(current application's NSUTF8StringEncoding) |error| :(missing value)) as text |
046 | #####テキストの内容 |
047 | log strReadData |
048 | ################################################ |
049 | ###可変テキスト初期化 |
050 | set ocidReadData to objNSMutableString's alloc()'s initWithCapacity:0 |
051 | ###テキストデータを流し込み |
052 | ocidReadData's setString:strReadData |
053 | ###↑文字数を数える |
054 | set numCntSampleText to ocidReadData's |length|() |
055 | ###↑文字数全部でレンジにする |
056 | set ocidNsRange to {location:0, |length|:numCntSampleText} |
057 | ###改行コード置き換え(CR/LF) |
058 | ocidReadData's replaceOccurrencesOfString:"\r\n" withString:"\n" options:0 range:ocidNsRange |
059 | ###↑文字数を数える |
060 | set numCntSampleText to ocidReadData's |length|() |
061 | ###↑文字数全部でレンジにする |
062 | set ocidNsRange to {location:0, |length|:numCntSampleText} |
063 | ###改行コード置き換え(CR) |
064 | ocidReadData's replaceOccurrencesOfString:"\r" withString:"\n" options:0 range:ocidNsRange |
065 | ###改行でリストにする |
066 | set ocidReadDataNSArray to ocidReadData's componentsSeparatedByString:"\n" |
067 | ##################### |
068 | set numLineNo to 0 as number |
069 | set strOutData to "" as text |
070 | ##### |
071 | repeat with objReadDataNSArray in ocidReadDataNSArray |
072 | set strReadDataNSArray to objReadDataNSArray as text |
073 | set numLineNo to numLineNo + 1 as number |
074 | if numLineNo < 100 then |
075 | set strZeroAdd to ("000" & numLineNo) as text |
076 | set strLineNo to text -3 through -1 of strZeroAdd as text |
077 | end if |
078 | set strOutData to strOutData & strLineNo & "\t" as text |
079 | set strOutData to strOutData & strReadDataNSArray & "\n" as text |
080 | end repeat |
081 | |
082 | ################################################ |
083 | ###処理が終わったテキスト |
084 | set ocidTempText to objNSString's stringWithString:strOutData |
085 | ###################### |
086 | ###フォルダのパス |
087 | ###デスクトップフォルダのパス |
088 | set aliasDirPath to (path to desktop folder from user domain) as alias |
089 | set strDirPath to POSIX path of aliasDirPath as text |
090 | ####作りたいファイル名(ここは今日の日付) |
091 | set strDateAndTimeJp to (my dateFormatterWithFormat:"yyyyMMdd-HHmm") |
092 | set strDistFilePath to ("" & strDirPath & ocidPrefixName & "-" & strDateAndTimeJp & ".txt") |
093 | |
094 | ###NSStringテキスト ファイルのパス |
095 | set objDistFilePath to objNSString's stringWithString:strDistFilePath |
096 | |
097 | ###ファイルを作る |
098 | set boolMakeNewFile to (objFileManager's createFileAtPath:objDistFilePath |contents|:ocidTempText attributes:(missing value)) |
099 | ####内容を書き込む UTF8で書き込む |
100 | set boolFileWrite to (ocidTempText's writeToFile:objDistFilePath atomically:false encoding:(objMe's NSUTF8StringEncoding) |error| :(missing value)) |
101 | |
102 | log boolMakeNewFile |
103 | log boolFileWrite |
104 | -->true or false |
105 | |
106 | |
107 | |
108 | |
109 | |
110 | ###日付のサブ |
111 | on dateFormatterWithFormat:classDateFormat |
112 | set formatter to objMe's NSDateFormatter's alloc()'s init() |
113 | formatter's setLocale:(objMe's NSLocale's localeWithLocaleIdentifier:"ja_JP_POSIX") |
114 | formatter's setDateFormat:(classDateFormat as string) |
115 | set theString to (formatter's stringFromDate:(current date)) as text |
116 | end dateFormatterWithFormat: |
117 | |
118 | |
AppleScriptで生成しました |
| 固定リンク
1:小文字を大文字に
2:大文字を小文字に
3:先頭大文字(キャピタライズ)に
1:小文字を大文字に
| 固定リンク
Accessibility Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Manifest Acrobat Menu Acrobat Open Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat python Acrobat Reader Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin Support Admin System Information Admin Tools Admin Users Admin Volumes Adobe Adobe FDKO Adobe RemoteUpdateManager AppKit Apple AppleScript AppleScript do shell script AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript System Events AppleScript System Events Plist AppleScript Video Applications AppStore Archive Attributes Automator BackUp Barcode Barcode QR Barcode QR Decode Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome CIImage CityCode CloudStorage Color com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time delimiters Desktop Device Diff Disk Dock DropBox Droplet eMail Encode % Encode Decode Encode UTF8 Error EXIFData ffmpeg File Finder Firefox Folder FolderAction Fonts GIF github Guide HTML HTML Entity Icon Illustrator Image Events Image2PDF ImageOptim iPhone iWork Javascript Jedit Json Label Leading Zero List locationd LRC lsappinfo LSSharedFileList m3u8 Mail MakePDF Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Mouse Music NetWork Notes NSArray NSArray Sort NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSColor NSColorList NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSPrintOperation NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth OneDrive PDF PDFAnnotation PDFAnnotationWidget PDFContext PDFDisplayBox PDFDocumentPermissions PDFImageRep PDFKit PDFnUP PDFOutline perl Photoshop PlistBuddy pluginkit postalcode PostScript prefPane Preview Python QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver SF Symbols character id SF Symbols Entity sips Skype Slack Sound Spotlight sqlite SRT StandardAdditions Swift System Settings TCC TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code VMware Fusion Wacom webarchive webp Wifi Windows XML XML EPUB XML OPML XML Plist XML RSS XML savedSearch XML SVG XML TTML XML webloc XML XMP YouTube zoom