{"id":19907572,"url":"https://github.com/abraham-ny/filetool","last_synced_at":"2025-03-01T08:14:47.524Z","repository":{"id":215935025,"uuid":"740079473","full_name":"abraham-ny/FileTool","owner":"abraham-ny","description":"File handler java library bringing the extra features that original Java Files package lacks.","archived":false,"fork":false,"pushed_at":"2024-01-07T13:24:16.000Z","size":52,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-01T08:14:44.203Z","etag":null,"topics":["archive","cross-platform","file-engine","file-handler","jar","java-library","java-library-starter","library","no-gui"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abraham-ny.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-07T13:18:11.000Z","updated_at":"2024-01-07T13:22:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"69d574e2-55f1-488f-bbc6-a5827e6efdcf","html_url":"https://github.com/abraham-ny/FileTool","commit_stats":null,"previous_names":["abummoja/filetool","abraham-nm/filetool","abraham-ny/filetool"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abraham-ny%2FFileTool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abraham-ny%2FFileTool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abraham-ny%2FFileTool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abraham-ny%2FFileTool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abraham-ny","download_url":"https://codeload.github.com/abraham-ny/FileTool/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241335590,"owners_count":19946085,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["archive","cross-platform","file-engine","file-handler","jar","java-library","java-library-starter","library","no-gui"],"created_at":"2024-11-12T20:42:09.689Z","updated_at":"2025-03-01T08:14:47.488Z","avatar_url":"https://github.com/abraham-ny.png","language":"Java","readme":"# File Tool\n**NB: Most of the code is PORTED from FileHandler(SWING GUI APP)**\n***\nJava Library to perform some extra file functions that are not implemented in the standard JDK.\u003cbr\u003e\nMade using JDK 17 and **ANT** but can also work on **any JDK** .\n\u003cbr\u003e\nVery lightweight, simple function calls and straight forward function names such as the ```removeWord()``` or ```getFileSize()``` functions in the ```FileTool``` class.\n\u003cbr\u003e**No external dependencies required**\n# Usage\n## Classes\n- FileMultiplier\n  - Generate multiple copies of a file given the file name.\n```\n//in this example I use a mail merging list of recipients\nint numberOfCopies = recipientsList.length;\nFileMultiplier mMultiplier;//no constructor needed\nmMultiplier.multiply(file.getName(), recipientDir(), numberOfCopies);\n//Done!\n```\n- FileOrganizer\n   - Organize files by moving them into folders based on the file extension\n   ```\n   FileOrganizer org = new FileOrganizer();\n   String musicExtensions = (FileTool)ft.audex;\n   org.iterateAndFilter(downloadsDir, musicExtensions);//returns String[]\n   //or use loadF(same params)\n   //throws IOException so you catch it!\n   //use clearList() after iterateFilter before you run another iteration\n   org.clearList();//clear the String[]\n   ```\n   - Move files from a dir to another.\n   ```\n   org.moveFiles(originalFilePath(string), newPath(string));\n   ```\n\n   - Move a ***String[ ]*** of fileNames(files) to a new directory\n   ```\n   //could not name moveFiles since ambiguous with above function\n   org.moveFi(destination(string), fileNameArr(String[]))\n   //throws IOException so catch or handle it!\n   ```\n\n- FileRenamer\n    - Remove repeated word in file names from a common directory\n    ```\n    FileRenamer rn = new FileRenamer();\n    String successStatus = rn.removeWordFromDir(dirName, wordToRemove, newWord /*or leave newWord AS EMPTY STRING to just remove word without replacing*/);\n    ```\n\n    - Remove repeated word from a list of files\n    ```\n    //Similar to above but instead of folder path, accepts List\u003cFile\u003e\n    rn.removeWordFromList(listOfFiles, word, new);\n    ```\n\n- FileTool\n    - Get file size in MB (MEGA bytes).\n    ```\n    //returns STRING\n    String fileSize = FileTool.getFileSize(pathToFile(string))\n    ```\n\n    ```\n    FileTool.print(String);\n    //simplified method for System.out.println(STRING);\n    //so you can just write shorter print statements.\n    ```\n\n    - Remove a word from a single file name\n    ```\n    FileTool.removeWord(word, filePath(string));\n    // simple\n    ```\n\n## Example Usage of Organizer\n```\n//process a folder to get what type of files are in it and how many (count) result as -\u003e \"Found 23 Documents...Videos...etc\"\npublic void processDirAndFiles() {\n   // TODO add your handling code here:\n   orgState.setText(\"Wait...\");\n   String fss1 = orgDestDir.getText();\n  if (\"\".equals(fss1)) {\n       orgDestDir.setText(\"You must select a folder to operate.\");\n   } else {\n       orgBtn.setVisible(true);\n       orgState.setText(\"Processing files...\");\n       String fss = \"C:\\\\Users\\\\\" + user + \"\\\\Documents\";\n\n       //fss1 should be the value of dir text\n       //music\n       loadF(FileUtil.archex, fss1);\n       zips = fo.files;\n       orgDirInfo.setText(\"Found: \" + zips.length + \" archives.\");\n       fo.clearList();\n       for (String sg : zips) {\n           System.out.println(sg);\n       }\n       orgProgBar.setValue(20);\n       fo.clearList();\n       //audio\n       loadF(FileUtil.audex, fss1);\n       auds = fo.files;\n       orgDirInfo.setText(orgDirInfo.getText() + \"\\n\" + \"Found: \" + auds.length + \" music.\");\n       fo.clearList();\n       for (String sg : auds) {\n           System.out.println(sg);\n       }\n       orgProgBar.setValue(20 + orgProgBar.getValue());\n       fo.clearList();\n       //videos\n       loadF(FileUtil.videx, fss1);\n       vids = fo.files;\n       orgDirInfo.setText(orgDirInfo.getText() + \"\\n\" + \"Found: \" + vids.length + \" videos.\");\n       fo.clearList();\n       for (String sg : vids) {\n           System.out.println(sg);\n       }\n       orgProgBar.setValue(20 + orgProgBar.getValue());\n       fo.clearList();\n       //pictures\n       loadF(FileUtil.picex, fss1);\n       pics = fo.files;\n       orgDirInfo.setText(orgDirInfo.getText() + \"\\n\" + \"Found: \" + pics.length + \" pictures.\");\n       fo.clearList();\n       for (String sg : pics) {\n           System.out.println(sg);\n       }\n       orgProgBar.setValue(20 + orgProgBar.getValue());\n       fo.clearList();\n       //documents\n       loadF(FileUtil.docex, fss1);\n       docs = fo.files;\n       orgDirInfo.setText(orgDirInfo.getText() + \"\\n\" + \"Found: \" + docs.length + \" documents.\");\n       fo.clearList();\n       for (String sg : docs) {\n           System.out.println(sg);\n       }\n       orgProgBar.setValue(20 + orgProgBar.getValue());\n       fo.clearList();\n       //apps\n       loadF(FileUtil.appex, fss1);\n       iapps = fo.files;\n       orgDirInfo.setText(orgDirInfo.getText() + \"\\n\" + \"Found: \" + iapps.length + \" executables.\");\n       fo.clearList();\n       for (String sg : iapps) {\n           System.out.println(sg);\n       }\n       orgProgBar.setValue(10 + orgProgBar.getValue());\n       fo.clearList();\n       orgProgBar.setIndeterminate(false);\n       orgProgBar.setMaximum(100);\n       orgProgBar.setValue(100);\n       //dmg.setVisible(false);\n   }\n\n}\n```\n\nAfter getting the dir file types info(optional), but useful to show to user you can now organize (enable the \"Organize\" button in your UI to allow user action) **Optional** but recommended\n\n```\nprivate void organizeBtnMouseClicked(java.awt.event.MouseEvent evt) {                                    \n    // TODO add your handling code here:\n    String fss = \"C:\\\\Users\\\\\" + user + \"\\\\Music\";\n    String o = orgDestDir.getText();\n    try {\n        fo.moveFi(uss.getDir(\"aar\"), zips);\n        orgCmplete.setText(\"Moved: \" + zips.length + \" archives\");\n        fo.moveFi(uss.getDir(\"mp4\"), vids);\n        orgCmplete.setText(orgCmplete.getText() + \"\\nMoved: \" + vids.length + \" videos\");\n        fo.moveFi(uss.getDir(\"mp3\"), auds);\n        orgCmplete.setText(orgCmplete.getText() + \"\\nMoved: \" + auds.length + \" Music\");\n        fo.moveFi(uss.getDir(\"doc\"), docs);\n        orgCmplete.setText(orgCmplete.getText() + \"\\nMoved: \" + docs.length + \" Documents\");\n        fo.moveFi(uss.getDir(\"app\"), iapps);\n        orgCmplete.setText(orgCmplete.getText() + \"\\nMoved: \" + iapps.length + \" executables\");\n        fo.moveFi(uss.getDir(\"pic\"), pics);\n        orgCmplete.setText(orgCmplete.getText() + \"\\nMoved: \" + pics.length + \" pics\");\n        //orgCmplete.setText(\"Success!\");\n    } catch (IOException ex) {\n        orgCmplete.setText(ex.getMessage());\n        Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);\n    }\n    updateOldList(o);\n}\n```\n\n# TODO\n - [ ] Add Zipping and Archiving features (zip, rar, jar, jad, gzip, 7z, tar...and more) if possible hence contributions are highly welcome\n - [ ] Edit file meta-data such as Dates, Owner...and more.\n### Contributing\nContributions are welcome, just clone the repo add your code then push and we'll check it out.\n**Forks** are also welcome.\n\n## Users\nDo you use this in your project(s)? we'd like to know or give us a mention.\n- List Of Users\n    - No users yet.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabraham-ny%2Ffiletool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabraham-ny%2Ffiletool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabraham-ny%2Ffiletool/lists"}