Guest User

Untitled

a guest
Jun 25th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. var files = Directory.GetFiles(@"C:DownloadsTemptest");
  2. foreach (var file in files)
  3. {
  4. if(file.Contains(".gif"))
  5. {
  6. string testing = string.Format("{0}.png", Path.GetFileNameWithoutExtension(file.Replace(".gif", "")));
  7. File.Move(file, @"C:DownloadsTemptest"+testing);
  8. }
  9. }
  10.  
  11. var files = new DirectoryInfo(@"c:files").GetFiles(@"*.gif");
  12. foreach (var file in files)
  13. File.Move(file.FullName, string.Format("{0}.gif", Path.GetFileNameWithoutExtension(file.FullName)));
  14.  
  15. var files = Directory.GetFiles(@"c:files", @"*.gif");
  16. foreach (var file in files)
  17. File.Move(file, string.Format("{0}.gif", Path.GetFileNameWithoutExtension(file)));
  18.  
  19. REM first rename all .gif.png to .gif
  20. for %i in (*.gif.png) do ren %i %~ni
  21.  
  22. REN then rename all .gif to .png
  23. for %i in (*.gif) do ren %~ni.gif %~ni.png
  24.  
  25. import java.io.File;
  26. import java.io.FilenameFilter;
  27. import java.util.regex.Matcher;
  28. import java.util.regex.Pattern;
  29.  
  30. public class Main
  31. {
  32. public static void main(final String[] argv)
  33. {
  34. final File dir;
  35. final File[] entries;
  36.  
  37. dir = new File(argv[0]);
  38. entries = dir.listFiles(new FilePatternFilter(".*\.gif\.png"));
  39.  
  40. for(final File entry : entries)
  41. {
  42. if(entry.isFile())
  43. {
  44. final String path;
  45. final String newPath;
  46. final File newEntry;
  47.  
  48. path = entry.getPath();
  49. newPath = path.substring(0, path.length() - "gif.png".length()) + "png";
  50. newEntry = new File(newPath);
  51.  
  52. if(!(entry.renameTo(newEntry)))
  53. {
  54. System.err.println("could not rename " + entry.getPath() +
  55. " to " + newEntry.getPath());
  56. }
  57. }
  58. }
  59. }
  60. }
  61.  
  62. @echo off
  63. setlocal enabledelayedexpansion enableextensions
  64. for %%f in (*.gif.png) do (
  65. set fn=%%f
  66. set fn=!fn:.gif=!
  67. ren "%%f" "!fn!"
  68. )
  69. endlocal
Add Comment
Please, Sign In to add comment